Skip to content

Commit 99db49f

Browse files
authored
feat!: update a2a.proto 0572953 (#606)
based on commit a2aproject/A2A@0572953 spec-grpc module has been regenerated from the updated a2a.proto Key changes: * Agent card * extendedAgentCard is not specified by capabilities (instead of `supportsExtendedAgentCard` field) * protocolVersions is a list (instead of a single `protocolVersion`) * SendMessage * `msg` field is now named `message` * ListTask * timestamp is now named statusTimestampAfter instead of `lastUpdatedAfter` * OAuthFlows * `deviceCode` has been added, `implicit` & `password` have been removed * AuthorizationCodeOAuthFlow * new `pkce_required` boolean field --------- Signed-off-by: Jeff Mesnil <jmesnil@ibm.com>
1 parent 7059c12 commit 99db49f

98 files changed

Lines changed: 2486 additions & 4477 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎client/base/src/main/java/io/a2a/client/AbstractClient.java‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -384,23 +384,23 @@ public abstract void resubscribe(@NonNull TaskIdParams request,
384384
@Nullable ClientCallContext context) throws A2AClientException;
385385

386386
/**
387-
* Retrieve the AgentCard.
387+
* Retrieve the extended AgentCard.
388388
*
389-
* @return the AgentCard
390-
* @throws A2AClientException if retrieving the agent card fails for any reason
389+
* @return the extended AgentCard
390+
* @throws A2AClientException if retrieving the extended agent card fails for any reason
391391
*/
392-
public AgentCard getAgentCard() throws A2AClientException {
393-
return getAgentCard(null);
392+
public AgentCard getExtendedAgentCard() throws A2AClientException {
393+
return getExtendedAgentCard(null);
394394
}
395395

396396
/**
397-
* Retrieve the AgentCard.
397+
* Retrieve the extended AgentCard.
398398
*
399399
* @param context optional client call context for the request (may be {@code null})
400-
* @return the AgentCard
401-
* @throws A2AClientException if retrieving the agent card fails for any reason
400+
* @return the extended AgentCard
401+
* @throws A2AClientException if retrieving the extended agent card fails for any reason
402402
*/
403-
public abstract AgentCard getAgentCard(@Nullable ClientCallContext context) throws A2AClientException;
403+
public abstract AgentCard getExtendedAgentCard(@Nullable ClientCallContext context) throws A2AClientException;
404404

405405
/**
406406
* Close the transport and release any associated resources.

‎client/base/src/main/java/io/a2a/client/Client.java‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -592,27 +592,28 @@ public void resubscribe(@NonNull TaskIdParams request,
592592
}
593593

594594
/**
595-
* Retrieve the agent's current agent card.
595+
* Retrieve the agent's extended agent card.
596596
* <p>
597-
* This method fetches the latest agent card from the agent. The card may have changed since
597+
* This method fetches the extended agent card from the agent (if the extendedAgentCard capability is supported).
598+
* The card may have changed since
598599
* client construction (e.g., new skills added, capabilities updated). The client's internal
599600
* reference is updated to the newly retrieved card.
600601
* <p>
601602
* Example:
602603
* <pre>{@code
603-
* AgentCard updatedCard = client.getAgentCard(null);
604+
* AgentCard updatedCard = client.getExtendedAgentCard(null);
604605
* System.out.println("Agent version: " + updatedCard.version());
605606
* System.out.println("Skills: " + updatedCard.skills().size());
606607
* }</pre>
607608
*
608609
* @param context custom call context for request interceptors (optional)
609-
* @return the agent's current agent card
610-
* @throws A2AClientException if the agent card cannot be retrieved
610+
* @return the agent's extended agent card
611+
* @throws A2AClientException if the extended agent card cannot be retrieved
611612
* @see AgentCard
612613
*/
613614
@Override
614-
public AgentCard getAgentCard(@Nullable ClientCallContext context) throws A2AClientException {
615-
agentCard = clientTransport.getAgentCard(context);
615+
public AgentCard getExtendedAgentCard(@Nullable ClientCallContext context) throws A2AClientException {
616+
agentCard = clientTransport.getExtendedAgentCard(context);
616617
return agentCard;
617618
}
618619

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void setUp() {
9090
.description("Test skill")
9191
.tags(Collections.singletonList("test"))
9292
.build()))
93-
.protocolVersion(CURRENT_PROTOCOL_VERSION)
93+
.protocolVersions(CURRENT_PROTOCOL_VERSION)
9494
.supportedInterfaces(java.util.Arrays.asList(
9595
new AgentInterface(TransportProtocol.JSONRPC.asString(), AGENT_URL),
9696
new AgentInterface(TransportProtocol.HTTP_JSON.asString(), AGENT_URL),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class ClientBuilderTest {
4242
.tags(Collections.singletonList("hello world"))
4343
.examples(List.of("hi", "hello world"))
4444
.build()))
45-
.protocolVersion(CURRENT_PROTOCOL_VERSION)
45+
.protocolVersions(CURRENT_PROTOCOL_VERSION)
4646
.supportedInterfaces(List.of(
4747
new AgentInterface(TransportProtocol.JSONRPC.asString(), "http://localhost:9999")))
4848
.build();

‎client/transport/grpc/src/main/java/io/a2a/client/transport/grpc/EventStreamObserver.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public EventStreamObserver(Consumer<StreamingEventKind> eventHandler, Consumer<T
2525
public void onNext(StreamResponse response) {
2626
StreamingEventKind event;
2727
switch (response.getPayloadCase()) {
28-
case MSG:
29-
event = FromProto.message(response.getMsg());
28+
case MESSAGE:
29+
event = FromProto.message(response.getMessage());
3030
break;
3131
case TASK:
3232
event = FromProto.task(response.getTask());

‎client/transport/grpc/src/main/java/io/a2a/client/transport/grpc/GrpcErrorMapper.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import io.a2a.common.A2AErrorMessages;
44
import io.a2a.spec.A2AClientException;
55
import io.a2a.spec.ContentTypeNotSupportedError;
6-
import io.a2a.spec.ExtendedCardNotConfiguredError;
6+
import io.a2a.spec.ExtendedAgentCardNotConfiguredError;
77
import io.a2a.spec.ExtensionSupportRequiredError;
88
import io.a2a.spec.InvalidAgentResponseError;
99
import io.a2a.spec.InvalidParamsError;
@@ -56,7 +56,7 @@ public static A2AClientException mapGrpcError(Throwable e, String errorPrefix) {
5656
} else if (description.contains("InvalidAgentResponseError")) {
5757
return new A2AClientException(errorPrefix + description, new InvalidAgentResponseError(null, description, null));
5858
} else if (description.contains("ExtendedCardNotConfiguredError")) {
59-
return new A2AClientException(errorPrefix + description, new ExtendedCardNotConfiguredError(null, description, null));
59+
return new A2AClientException(errorPrefix + description, new ExtendedAgentCardNotConfiguredError(null, description, null));
6060
} else if (description.contains("ExtensionSupportRequiredError")) {
6161
return new A2AClientException(errorPrefix + description, new ExtensionSupportRequiredError(null, description, null));
6262
} else if (description.contains("VersionNotSupportedError")) {

‎client/transport/grpc/src/main/java/io/a2a/client/transport/grpc/GrpcTransport.java‎

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static io.a2a.spec.A2AMethods.CANCEL_TASK_METHOD;
44
import static io.a2a.spec.A2AMethods.DELETE_TASK_PUSH_NOTIFICATION_CONFIG_METHOD;
5+
import static io.a2a.spec.A2AMethods.GET_EXTENDED_AGENT_CARD_METHOD;
56
import static io.a2a.spec.A2AMethods.GET_TASK_METHOD;
67
import static io.a2a.spec.A2AMethods.GET_TASK_PUSH_NOTIFICATION_CONFIG_METHOD;
78
import static io.a2a.spec.A2AMethods.LIST_TASK_METHOD;
@@ -26,6 +27,7 @@
2627
import io.a2a.grpc.A2AServiceGrpc;
2728
import io.a2a.grpc.A2AServiceGrpc.A2AServiceBlockingV2Stub;
2829
import io.a2a.grpc.A2AServiceGrpc.A2AServiceStub;
30+
import io.a2a.grpc.GetExtendedAgentCardRequest;
2931
import io.a2a.grpc.utils.ProtoUtils.FromProto;
3032
import io.a2a.grpc.utils.ProtoUtils.ToProto;
3133
import io.a2a.jsonrpc.common.wrappers.ListTasksResult;
@@ -65,7 +67,7 @@ public class GrpcTransport implements ClientTransport {
6567
private final A2AServiceBlockingV2Stub blockingStub;
6668
private final A2AServiceStub asyncStub;
6769
private final @Nullable List<ClientCallInterceptor> interceptors;
68-
private AgentCard agentCard;
70+
private final AgentCard agentCard;
6971
private final String agentTenant;
7072

7173
public GrpcTransport(Channel channel, AgentCard agentCard) {
@@ -104,8 +106,8 @@ public EventKind sendMessage(MessageSendParams request, @Nullable ClientCallCont
104106
try {
105107
A2AServiceBlockingV2Stub stubWithMetadata = createBlockingStubWithMetadata(context, payloadAndHeaders);
106108
io.a2a.grpc.SendMessageResponse response = stubWithMetadata.sendMessage(sendMessageRequest);
107-
if (response.hasMsg()) {
108-
return FromProto.message(response.getMsg());
109+
if (response.hasMessage()) {
110+
return FromProto.message(response.getMessage());
109111
} else if (response.hasTask()) {
110112
return FromProto.task(response.getTask());
111113
} else {
@@ -195,8 +197,12 @@ public ListTasksResult listTasks(ListTasksParams request, @Nullable ClientCallCo
195197
if (request.historyLength() != null) {
196198
requestBuilder.setHistoryLength(request.historyLength());
197199
}
198-
if (request.lastUpdatedAfter() != null) {
199-
requestBuilder.setLastUpdatedAfter(request.lastUpdatedAfter().toEpochMilli());
200+
if (request.statusTimestampAfter() != null) {
201+
requestBuilder.setStatusTimestampAfter(
202+
com.google.protobuf.Timestamp.newBuilder()
203+
.setSeconds(request.statusTimestampAfter().getEpochSecond())
204+
.setNanos(request.statusTimestampAfter().getNano())
205+
.build());
200206
}
201207
if (request.includeArtifacts() != null) {
202208
requestBuilder.setIncludeArtifacts(request.includeArtifacts());
@@ -344,9 +350,19 @@ private MessageSendParams createRequestWithTenant(MessageSendParams request) {
344350
}
345351

346352
@Override
347-
public AgentCard getAgentCard(@Nullable ClientCallContext context) throws A2AClientException {
348-
// TODO: Determine how to handle retrieving the authenticated extended agent card
349-
return agentCard;
353+
public AgentCard getExtendedAgentCard(@Nullable ClientCallContext context) throws A2AClientException {
354+
GetExtendedAgentCardRequest request = GetExtendedAgentCardRequest.newBuilder()
355+
.build();
356+
PayloadAndHeaders payloadAndHeaders = applyInterceptors(GET_EXTENDED_AGENT_CARD_METHOD, request, agentCard, context);
357+
358+
try {
359+
A2AServiceBlockingV2Stub stubWithMetadata = createBlockingStubWithMetadata(context, payloadAndHeaders);
360+
io.a2a.grpc.AgentCard response = stubWithMetadata.getExtendedAgentCard(request);
361+
362+
return FromProto.agentCard(response);
363+
} catch (StatusRuntimeException | StatusException e) {
364+
throw GrpcErrorMapper.mapGrpcError(e, "Failed to get extended agent card: ");
365+
}
350366
}
351367

352368
@Override

‎client/transport/grpc/src/test/java/io/a2a/client/transport/grpc/GrpcErrorMapperTest.java‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@
77

88
import io.a2a.spec.A2AClientException;
99
import io.a2a.spec.ContentTypeNotSupportedError;
10-
import io.a2a.spec.ExtendedCardNotConfiguredError;
10+
import io.a2a.spec.ExtendedAgentCardNotConfiguredError;
1111
import io.a2a.spec.ExtensionSupportRequiredError;
12-
import io.a2a.spec.InvalidAgentResponseError;
1312
import io.a2a.spec.InvalidParamsError;
14-
import io.a2a.spec.InvalidRequestError;
15-
import io.a2a.spec.JSONParseError;
16-
import io.a2a.spec.MethodNotFoundError;
17-
import io.a2a.spec.PushNotificationNotSupportedError;
18-
import io.a2a.spec.TaskNotCancelableError;
1913
import io.a2a.spec.TaskNotFoundError;
2014
import io.a2a.spec.UnsupportedOperationError;
2115
import io.a2a.spec.VersionNotSupportedError;
@@ -85,9 +79,9 @@ public void testExtendedCardNotConfiguredErrorUnmarshalling() {
8579
// Verify the result
8680
assertNotNull(result);
8781
assertNotNull(result.getCause());
88-
assertInstanceOf(ExtendedCardNotConfiguredError.class, result.getCause());
82+
assertInstanceOf(ExtendedAgentCardNotConfiguredError.class, result.getCause());
8983

90-
ExtendedCardNotConfiguredError extendedCardError = (ExtendedCardNotConfiguredError) result.getCause();
84+
ExtendedAgentCardNotConfiguredError extendedCardError = (ExtendedAgentCardNotConfiguredError) result.getCause();
9185
assertNotNull(extendedCardError.getMessage());
9286
assertTrue(extendedCardError.getMessage().contains("Extended card not configured"));
9387
}

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

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.function.Consumer;
2222

2323
import com.google.protobuf.MessageOrBuilder;
24-
import io.a2a.client.http.A2ACardResolver;
24+
2525
import io.a2a.client.http.A2AHttpClient;
2626
import io.a2a.client.http.A2AHttpClientFactory;
2727
import io.a2a.client.http.A2AHttpResponse;
@@ -33,12 +33,10 @@
3333
import io.a2a.grpc.utils.JSONRPCUtils;
3434
import io.a2a.grpc.utils.ProtoUtils;
3535
import io.a2a.jsonrpc.common.json.JsonProcessingException;
36-
import io.a2a.jsonrpc.common.wrappers.A2AMessage;
3736
import io.a2a.jsonrpc.common.wrappers.A2AResponse;
3837
import io.a2a.jsonrpc.common.wrappers.CancelTaskResponse;
3938
import io.a2a.jsonrpc.common.wrappers.DeleteTaskPushNotificationConfigResponse;
40-
import io.a2a.jsonrpc.common.wrappers.GetAuthenticatedExtendedCardRequest;
41-
import io.a2a.jsonrpc.common.wrappers.GetAuthenticatedExtendedCardResponse;
39+
import io.a2a.jsonrpc.common.wrappers.GetExtendedAgentCardResponse;
4240
import io.a2a.jsonrpc.common.wrappers.GetTaskPushNotificationConfigResponse;
4341
import io.a2a.jsonrpc.common.wrappers.GetTaskResponse;
4442
import io.a2a.jsonrpc.common.wrappers.ListTaskPushNotificationConfigResponse;
@@ -71,8 +69,7 @@ public class JSONRPCTransport implements ClientTransport {
7169
private final A2AHttpClient httpClient;
7270
private final AgentInterface agentInterface;
7371
private final @Nullable List<ClientCallInterceptor> interceptors;
74-
private @Nullable AgentCard agentCard;
75-
private boolean needsExtendedCard = false;
72+
private final @Nullable AgentCard agentCard;
7673

7774
public JSONRPCTransport(String agentUrl) {
7875
this(null, null, new AgentInterface("JSONRPC", agentUrl), null);
@@ -88,7 +85,6 @@ public JSONRPCTransport(@Nullable A2AHttpClient httpClient, @Nullable AgentCard
8885
this.agentCard = agentCard;
8986
this.agentInterface = agentInterface;
9087
this.interceptors = interceptors;
91-
this.needsExtendedCard = agentCard == null || agentCard.supportsExtendedAgentCard();
9288
}
9389

9490
@Override
@@ -288,31 +284,15 @@ public void resubscribe(TaskIdParams request, Consumer<StreamingEventKind> event
288284
}
289285

290286
@Override
291-
public AgentCard getAgentCard(@Nullable ClientCallContext context) throws A2AClientException {
292-
A2ACardResolver resolver;
287+
public AgentCard getExtendedAgentCard(@Nullable ClientCallContext context) throws A2AClientException {
293288
try {
294-
if (agentCard == null) {
295-
resolver = new A2ACardResolver(httpClient, agentInterface.url(), agentInterface.tenant(), null, getHttpHeaders(context));
296-
agentCard = resolver.getAgentCard();
297-
needsExtendedCard = agentCard.supportsExtendedAgentCard();
298-
}
299-
if (!needsExtendedCard) {
300-
return agentCard;
301-
}
302-
303-
GetAuthenticatedExtendedCardRequest getExtendedAgentCardRequest = GetAuthenticatedExtendedCardRequest.builder()
304-
.jsonrpc(A2AMessage.JSONRPC_VERSION)
305-
.build(); // id will be randomly generated
306-
307289
PayloadAndHeaders payloadAndHeaders = applyInterceptors(GET_EXTENDED_AGENT_CARD_METHOD,
308290
ProtoUtils.ToProto.extendedAgentCard(), agentCard, context);
309291

310292
try {
311293
String httpResponseBody = sendPostRequest(Utils.buildBaseUrl(agentInterface, ""), payloadAndHeaders, GET_EXTENDED_AGENT_CARD_METHOD);
312-
GetAuthenticatedExtendedCardResponse response = unmarshalResponse(httpResponseBody, GET_EXTENDED_AGENT_CARD_METHOD);
313-
agentCard = response.getResult();
314-
needsExtendedCard = false;
315-
return agentCard;
294+
GetExtendedAgentCardResponse response = unmarshalResponse(httpResponseBody, GET_EXTENDED_AGENT_CARD_METHOD);
295+
return response.getResult();
316296
} catch (IOException | InterruptedException | JsonProcessingException e) {
317297
throw new A2AClientException("Failed to get authenticated extended agent card: " + e, e);
318298
}

0 commit comments

Comments
 (0)