Skip to content

Commit f71c698

Browse files
authored
feat!: Align spec classes with the a2a.proto, removing compatibility code (#546)
We do not need to stay compliant with 0.x.0 versions of the spec, and it should be more stable after 1.0. Note this does not remove the 'kind' field, which will be done in #544
1 parent 6aad9cd commit f71c698

File tree

79 files changed

+1649
-107
lines changed

Some content is hidden

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

79 files changed

+1649
-107
lines changed

spec-grpc/src/main/java/io/a2a/grpc/mapper/AgentCardMapper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ public interface AgentCardMapper {
2222

2323
AgentCardMapper INSTANCE = A2AMappers.getMapper(AgentCardMapper.class);
2424

25+
// Deprecated proto fields - not present in spec API (removed in 1.0.0)
26+
@Mapping(target = "url", ignore = true)
27+
@Mapping(target = "preferredTransport", ignore = true)
28+
@Mapping(target = "additionalInterfaces", ignore = true)
2529
@Mapping(target = "provider", source = "provider", conditionExpression = "java(domain.provider() != null)")
2630
@Mapping(target = "documentationUrl", source = "documentationUrl", conditionExpression = "java(domain.documentationUrl() != null)")
2731
@Mapping(target = "iconUrl", source = "iconUrl", conditionExpression = "java(domain.iconUrl() != null)")
28-
@Mapping(target = "url", ignore = true) // Deprecated in proto, derived from supportedInterfaces[0]
29-
@Mapping(target = "preferredTransport", ignore = true) // Deprecated in proto, derived from supportedInterfaces[0]
30-
@Mapping(target = "additionalInterfaces", ignore = true) // Deprecated in proto, use supportedInterfaces instead
3132
io.a2a.grpc.AgentCard toProto(io.a2a.spec.AgentCard domain);
3233

3334
@Mapping(target = "provider", source = "provider", conditionExpression = "java(proto.hasProvider())")

spec-grpc/src/main/java/io/a2a/grpc/mapper/TaskStatusUpdateEventMapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public interface TaskStatusUpdateEventMapper {
2020
/**
2121
* Converts domain TaskStatusUpdateEvent to proto.
2222
* Uses declarative mapping with CommonFieldMapper for metadata conversion.
23+
* Note: MapStruct derives property "final" from domain's isFinal() getter (strips "is" prefix).
2324
*/
2425
@Mapping(target = "metadata", source = "metadata", qualifiedByName = "metadataToProto")
2526
@Mapping(target = "final", source = "final")

spec/src/main/java/io/a2a/json/JsonUtil.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858

5959
import static io.a2a.json.JsonUtil.JSONRPCErrorTypeAdapter.THROWABLE_MARKER_FIELD;
6060

61+
/**
62+
* Utility class for JSON operations.
63+
*/
6164
public class JsonUtil {
6265

6366
private static GsonBuilder createBaseGsonBuilder() {
@@ -86,6 +89,15 @@ private static GsonBuilder createBaseGsonBuilder() {
8689
.registerTypeHierarchyAdapter(StreamingEventKind.class, new StreamingEventKindTypeAdapter())
8790
.create();
8891

92+
/**
93+
* Deserializes JSON string to an object of the specified class.
94+
*
95+
* @param <T> the type of the object to deserialize to
96+
* @param json the JSON string to parse
97+
* @param classOfT the class of the object to deserialize to
98+
* @return the deserialized object
99+
* @throws JsonProcessingException if JSON parsing fails
100+
*/
89101
public static <T> T fromJson(String json, Class<T> classOfT) throws JsonProcessingException {
90102
try {
91103
return OBJECT_MAPPER.fromJson(json, classOfT);
@@ -94,6 +106,15 @@ public static <T> T fromJson(String json, Class<T> classOfT) throws JsonProcessi
94106
}
95107
}
96108

109+
/**
110+
* Deserializes JSON string to an object of the specified type.
111+
*
112+
* @param <T> the type of the object to deserialize to
113+
* @param json the JSON string to parse
114+
* @param type the type of the object to deserialize to (supports generics)
115+
* @return the deserialized object
116+
* @throws JsonProcessingException if JSON parsing fails
117+
*/
97118
public static <T> T fromJson(String json, Type type) throws JsonProcessingException {
98119
try {
99120
return OBJECT_MAPPER.fromJson(json, type);
@@ -110,6 +131,7 @@ public static <T> T fromJson(String json, Type type) throws JsonProcessingExcept
110131
*
111132
* @param data the object to serialize
112133
* @return JSON string representation of the object
134+
* @throws JsonProcessingException if conversion fails
113135
*/
114136
public static String toJson(Object data) throws JsonProcessingException {
115137
try {

spec/src/main/java/io/a2a/spec/A2AClientHTTPError.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@
3030
* @see <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status">HTTP Status Codes</a>
3131
*/
3232
public class A2AClientHTTPError extends A2AClientError {
33+
/**
34+
* The HTTP status code.
35+
*/
3336
private final int code;
37+
38+
/**
39+
* The error message.
40+
*/
3441
private final String message;
3542

3643
/**

spec/src/main/java/io/a2a/spec/AgentCard.java

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
* <p>
1919
* This class is immutable and uses the Builder pattern for construction to handle the mix of
2020
* required and optional fields defined by the specification.
21+
* <p>
22+
* <b>Important:</b> The {@link #supportedInterfaces()} field specifies how clients can
23+
* communicate with the agent. Each entry combines a protocol binding (e.g., "JSONRPC",
24+
* "GRPC") with a URL endpoint. The first entry in the list is the preferred interface.
2125
*
2226
* @param name the human-readable name of the agent (required)
2327
* @param description a brief description of the agent's purpose and functionality (required)
@@ -32,9 +36,10 @@
3236
* @param securitySchemes map of security scheme names to their definitions (optional)
3337
* @param security list of security requirements for accessing the agent (optional)
3438
* @param iconUrl URL to an icon representing the agent (optional)
35-
* @param supportedInterfaces ordered list of supported interfaces. First entry is preferred. (required)
39+
* @param supportedInterfaces ordered list of protocol+URL interface combinations; first entry is preferred (required)
3640
* @param protocolVersion the version of the A2A Protocol this agent implements (defaults to {@link #DEFAULT_PROTOCOL_VERSION})
3741
* @param signatures digital signatures verifying the authenticity of the agent card (optional)
42+
* @see AgentInterface
3843
* @see <a href="https://a2a-protocol.org/latest/">A2A Protocol Specification</a>
3944
*/
4045
public record AgentCard(
@@ -61,6 +66,22 @@ public record AgentCard(
6166
/**
6267
* Compact constructor that validates required fields and sets defaults.
6368
*
69+
* @param name the name parameter (see class-level JavaDoc)
70+
* @param description the description parameter (see class-level JavaDoc)
71+
* @param provider the provider parameter (see class-level JavaDoc)
72+
* @param version the version parameter (see class-level JavaDoc)
73+
* @param documentationUrl the documentationUrl parameter (see class-level JavaDoc)
74+
* @param capabilities the capabilities parameter (see class-level JavaDoc)
75+
* @param defaultInputModes the defaultInputModes parameter (see class-level JavaDoc)
76+
* @param defaultOutputModes the defaultOutputModes parameter (see class-level JavaDoc)
77+
* @param skills the skills parameter (see class-level JavaDoc)
78+
* @param supportsExtendedAgentCard the supportsExtendedAgentCard parameter (see class-level JavaDoc)
79+
* @param securitySchemes the securitySchemes parameter (see class-level JavaDoc)
80+
* @param security the security parameter (see class-level JavaDoc)
81+
* @param iconUrl the iconUrl parameter (see class-level JavaDoc)
82+
* @param supportedInterfaces the supportedInterfaces parameter (see class-level JavaDoc)
83+
* @param protocolVersion the protocolVersion parameter (see class-level JavaDoc)
84+
* @param signatures the signatures parameter (see class-level JavaDoc)
6485
* @throws IllegalArgumentException if any required field is null
6586
*/
6687
public AgentCard {
@@ -78,17 +99,6 @@ public record AgentCard(
7899
}
79100
}
80101

81-
/**
82-
* Returns the list of additional interfaces.
83-
*
84-
* @return the list of supported interfaces
85-
* @deprecated Use {@link #supportedInterfaces()} instead. This field has been renamed to 'supportedInterfaces'.
86-
*/
87-
@Deprecated(since = "0.4.0", forRemoval = true)
88-
public List<AgentInterface> additionalInterfaces() {
89-
return supportedInterfaces;
90-
}
91-
92102
/**
93103
* Create a new Builder
94104
*
@@ -362,11 +372,21 @@ public Builder iconUrl(String iconUrl) {
362372
}
363373

364374
/**
365-
* Sets the ordered list of supported interfaces (first entry is preferred).
375+
* Sets the ordered list of supported protocol interfaces (first entry is preferred).
376+
* <p>
377+
* Each interface defines a combination of protocol binding (e.g., "JSONRPC", "GRPC", "REST")
378+
* and URL endpoint for accessing the agent. This is the primary field for declaring how
379+
* clients can communicate with the agent as of protocol version 1.0.0.
366380
* <p>
367-
* Each interface defines a combination of protocol binding and URL for accessing the agent.
381+
* Example:
382+
* <pre>{@code
383+
* .supportedInterfaces(List.of(
384+
* new AgentInterface("JSONRPC", "http://localhost:9999"),
385+
* new AgentInterface("GRPC", "grpc://localhost:9090")
386+
* ))
387+
* }</pre>
368388
*
369-
* @param supportedInterfaces the ordered list of supported interfaces (optional)
389+
* @param supportedInterfaces the ordered list of supported interfaces (required)
370390
* @return this builder for method chaining
371391
* @see AgentInterface
372392
*/

spec/src/main/java/io/a2a/spec/AgentCardSignature.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public record AgentCardSignature(Map<String, Object> header, @SerializedName("pr
3737
/**
3838
* Compact constructor that validates required fields.
3939
*
40+
* @param header the header parameter (see class-level JavaDoc)
41+
* @param protectedHeader the protectedHeader parameter (see class-level JavaDoc)
42+
* @param signature the signature parameter (see class-level JavaDoc)
4043
* @throws IllegalArgumentException if protectedHeader or signature is null
4144
*/
4245
public AgentCardSignature {

spec/src/main/java/io/a2a/spec/AgentExtension.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ public record AgentExtension (String description, Map<String, Object> params, bo
2828
/**
2929
* Compact constructor that validates required fields.
3030
*
31+
* @param description the description parameter (see class-level JavaDoc)
32+
* @param params the params parameter (see class-level JavaDoc)
33+
* @param required the required parameter (see class-level JavaDoc)
34+
* @param uri the uri parameter (see class-level JavaDoc)
3135
* @throws IllegalArgumentException if uri is null
3236
*/
3337
public AgentExtension {

spec/src/main/java/io/a2a/spec/AgentInterface.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
* are JSONRPC, GRPC, and HTTP+JSON.
1212
* <p>
1313
* Agents may support multiple interfaces to allow flexibility in how clients communicate.
14-
* The {@link AgentCard} includes a primary interface (url + preferredTransport) and may
15-
* list additional interfaces for alternative access methods.
14+
* The {@link AgentCard#supportedInterfaces()} field contains an ordered list of interfaces,
15+
* with the first entry being the preferred method for accessing the agent.
1616
* <p>
1717
* This class is immutable.
1818
*
@@ -29,6 +29,9 @@ public record AgentInterface(String protocolBinding, String url, String tenant)
2929
/**
3030
* Compact constructor that validates required fields.
3131
*
32+
* @param protocolBinding the protocolBinding parameter (see class-level JavaDoc)
33+
* @param url the url parameter (see class-level JavaDoc)
34+
* @param tenant the tenant parameter (see class-level JavaDoc)
3235
* @throws IllegalArgumentException if protocolBinding or url is null
3336
*/
3437
public AgentInterface {
@@ -37,6 +40,12 @@ public record AgentInterface(String protocolBinding, String url, String tenant)
3740
Assert.checkNotNullParam("tenant", tenant);
3841
}
3942

43+
/**
44+
* Convenience constructor for creating an AgentInterface without a tenant.
45+
*
46+
* @param protocolBinding the protocol binding (see class-level JavaDoc)
47+
* @param url the endpoint URL (see class-level JavaDoc)
48+
*/
4049
public AgentInterface(String protocolBinding, String url) {
4150
this(protocolBinding, url, "");
4251
}

spec/src/main/java/io/a2a/spec/AgentProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public record AgentProvider(String organization, String url) {
2424
/**
2525
* Compact constructor that validates required fields.
2626
*
27+
* @param organization the organization parameter (see class-level JavaDoc)
28+
* @param url the url parameter (see class-level JavaDoc)
2729
* @throws IllegalArgumentException if organization or url is null
2830
*/
2931
public AgentProvider {

spec/src/main/java/io/a2a/spec/AgentSkill.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ public record AgentSkill(String id, String name, String description, List<String
4646
/**
4747
* Compact constructor that validates required fields.
4848
*
49+
* @param id the id parameter (see class-level JavaDoc)
50+
* @param name the name parameter (see class-level JavaDoc)
51+
* @param description the description parameter (see class-level JavaDoc)
52+
* @param tags the tags parameter (see class-level JavaDoc)
53+
* @param examples the examples parameter (see class-level JavaDoc)
54+
* @param inputModes the inputModes parameter (see class-level JavaDoc)
55+
* @param outputModes the outputModes parameter (see class-level JavaDoc)
56+
* @param security the security parameter (see class-level JavaDoc)
4957
* @throws IllegalArgumentException if id, name, description, or tags is null
5058
*/
5159
public AgentSkill {

0 commit comments

Comments
 (0)