schemes) {
+ this.schemes = schemes;
+ return this;
+ }
+
+ /**
+ * Sets the credentials for push notification authentication.
+ * These credentials are used to authenticate with the push notification
+ * service when delivering notifications to clients.
+ *
+ * @param credentials the authentication credentials
+ * @return this builder instance for method chaining
+ */
+ public Builder credentials(String credentials) {
+ this.credentials = credentials;
+ return this;
+ }
+
+ /**
+ * Builds and returns a new PushNotificationAuthenticationInfo instance.
+ *
+ * @return a new PushNotificationAuthenticationInfo with the configured settings
+ */
+ public PushNotificationAuthenticationInfo build() {
+ return new PushNotificationAuthenticationInfo(schemes, credentials);
+ }
+ }
}
diff --git a/spec/src/main/java/io/a2a/spec/PushNotificationConfig.java b/spec/src/main/java/io/a2a/spec/PushNotificationConfig.java
index 34270637f..202a5bd07 100644
--- a/spec/src/main/java/io/a2a/spec/PushNotificationConfig.java
+++ b/spec/src/main/java/io/a2a/spec/PushNotificationConfig.java
@@ -5,7 +5,24 @@
import io.a2a.util.Assert;
/**
- * Represents a push notification.
+ * Represents the configuration for push notifications in the A2A protocol.
+ * This record defines the settings and parameters required to enable and configure
+ * push notification delivery for agent-to-application communication.
+ *
+ * Push notifications provide a mechanism for agents to proactively notify client
+ * applications about important events, task updates, or status changes without
+ * requiring the client to continuously poll for updates. This improves efficiency
+ * and user experience by enabling real-time communication.
+ *
+ * The configuration includes:
+ *
+ * - Authentication Information: Credentials and schemes for push services
+ * - Delivery Settings: How and when notifications should be sent
+ * - Service Configuration: Provider-specific settings and endpoints
+ *
+ *
+ * This implementation supports various push notification providers and protocols,
+ * allowing flexible integration with different client platforms and notification systems.
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -15,10 +32,18 @@ public record PushNotificationConfig(String url, String token, PushNotificationA
Assert.checkNotNullParam("url", url);
}
+ /**
+ * Builder class for constructing PushNotificationConfig instances.
+ * Provides a fluent API for configuring push notification settings.
+ */
public static class Builder {
+ /** The URL endpoint for push notification delivery */
private String url;
+ /** The authentication token for push notification services */
private String token;
+ /** The authentication information for push notifications */
private PushNotificationAuthenticationInfo authentication;
+ /** Unique identifier for this push notification configuration */
private String id;
public Builder() {
@@ -30,27 +55,52 @@ public Builder(PushNotificationConfig notificationConfig) {
this.authentication = notificationConfig.authentication;
this.id = notificationConfig.id;
}
-
+
public Builder url(String url) {
this.url = url;
return this;
}
+ /**
+ * Sets the authentication token for push notification services.
+ *
+ * @param token the authentication token
+ * @return this builder instance for method chaining
+ */
public Builder token(String token) {
this.token = token;
return this;
}
+ /**
+ * Sets the authentication information for push notifications.
+ * This information is used to authenticate with push notification services
+ * when delivering notifications to client applications.
+ *
+ * @param authenticationInfo the authentication configuration for push notifications
+ * @return this builder instance for method chaining
+ */
public Builder authenticationInfo(PushNotificationAuthenticationInfo authenticationInfo) {
this.authentication = authenticationInfo;
return this;
}
+ /**
+ * Sets the unique identifier for this push notification configuration.
+ *
+ * @param id the unique identifier
+ * @return this builder instance for method chaining
+ */
public Builder id(String id) {
this.id = id;
return this;
}
+ /**
+ * Builds and returns a new PushNotificationConfig instance.
+ *
+ * @return a new PushNotificationConfig with the configured settings
+ */
public PushNotificationConfig build() {
return new PushNotificationConfig(url, token, authentication, id);
}
diff --git a/spec/src/main/java/io/a2a/spec/PushNotificationNotSupportedError.java b/spec/src/main/java/io/a2a/spec/PushNotificationNotSupportedError.java
index d639b7bab..a2cd7c84f 100644
--- a/spec/src/main/java/io/a2a/spec/PushNotificationNotSupportedError.java
+++ b/spec/src/main/java/io/a2a/spec/PushNotificationNotSupportedError.java
@@ -7,10 +7,27 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * Represents a JSON-RPC error indicating that push notifications are not supported.
+ * This error is returned when a client attempts to configure or use push notification
+ * functionality on an agent that does not support this feature.
+ *
+ * This error follows the JSON-RPC 2.0 error specification and uses a specific
+ * error code (-32003) to identify push notification support issues. It extends
+ * the base JSONRPCError class to provide structured error information.
+ *
+ * Common scenarios where this error occurs:
+ *
+ * - Attempting to set task push notification configuration on an unsupported agent
+ * - Trying to enable push notifications when the agent lacks the capability
+ * - Requesting push notification features in environments where they're disabled
+ *
+ */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public class PushNotificationNotSupportedError extends JSONRPCError {
+ /** The default error code for push notification not supported errors */
public final static Integer DEFAULT_CODE = -32003;
public PushNotificationNotSupportedError() {
diff --git a/spec/src/main/java/io/a2a/spec/SecurityScheme.java b/spec/src/main/java/io/a2a/spec/SecurityScheme.java
index 5003d01aa..4c596f876 100644
--- a/spec/src/main/java/io/a2a/spec/SecurityScheme.java
+++ b/spec/src/main/java/io/a2a/spec/SecurityScheme.java
@@ -5,6 +5,24 @@
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
+/**
+ * Sealed interface representing security schemes in the A2A protocol.
+ *
+ * This interface defines the contract for various authentication and authorization
+ * mechanisms that can be used to secure A2A agent communications. The interface
+ * uses Jackson annotations to support polymorphic JSON serialization and
+ * deserialization based on the "type" property.
+ *
+ *
+ * Supported security scheme types:
+ *
+ *
+ * - {@link APIKeySecurityScheme} - API key-based authentication
+ * - {@link HTTPAuthSecurityScheme} - HTTP authentication (Basic, Bearer, etc.)
+ * - {@link OAuth2SecurityScheme} - OAuth 2.0 authentication
+ * - {@link OpenIdConnectSecurityScheme} - OpenID Connect authentication
+ *
+ */
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
@@ -19,5 +37,10 @@
})
public sealed interface SecurityScheme permits APIKeySecurityScheme, HTTPAuthSecurityScheme, OAuth2SecurityScheme, OpenIdConnectSecurityScheme {
+ /**
+ * Gets the description of this security scheme.
+ *
+ * @return a human-readable description of the security scheme
+ */
String getDescription();
}
diff --git a/spec/src/main/java/io/a2a/spec/SendMessageRequest.java b/spec/src/main/java/io/a2a/spec/SendMessageRequest.java
index d31f364e4..d5eac36b2 100644
--- a/spec/src/main/java/io/a2a/spec/SendMessageRequest.java
+++ b/spec/src/main/java/io/a2a/spec/SendMessageRequest.java
@@ -12,14 +12,45 @@
import io.a2a.util.Assert;
/**
- * Used to send a message request.
+ * Represents a JSON-RPC request for sending a message to an agent in the A2A protocol.
+ * This request is used to initiate message communication with an agent, allowing clients
+ * to send various types of messages including text, images, and other content.
+ *
+ * The SendMessageRequest follows the JSON-RPC 2.0 specification and uses the
+ * "message/send" method. It encapsulates message parameters and configuration
+ * options for delivery and processing.
+ *
+ * This is a non-streaming request, meaning it expects a single response
+ * rather than a stream of responses. For streaming message scenarios,
+ * use SendStreamingMessageRequest instead.
+ *
+ * Example usage:
+ *
+ * MessageSendParams params = new MessageSendParams.Builder()
+ * .message("Hello, agent!")
+ * .build();
+ * SendMessageRequest request = new SendMessageRequest("request-123", params);
+ *
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public final class SendMessageRequest extends NonStreamingJSONRPCRequest {
+ /** The JSON-RPC method name for sending messages */
public static final String METHOD = "message/send";
+ /**
+ * Creates a new SendMessageRequest with full parameter specification.
+ *
+ * @param jsonrpc the JSON-RPC protocol version (must be "2.0")
+ * @param id the request identifier (string, number, or null)
+ * @param method the JSON-RPC method name (must be "message/send")
+ * @param params the message parameters containing the message content and configuration
+ * @throws IllegalArgumentException if jsonrpc is null, empty, or not "2.0"
+ * @throws IllegalArgumentException if method is not "message/send"
+ * @throws IllegalArgumentException if params is null
+ * @throws IllegalArgumentException if id is not null, string, or integer
+ */
@JsonCreator
public SendMessageRequest(@JsonProperty("jsonrpc") String jsonrpc, @JsonProperty("id") Object id,
@JsonProperty("method") String method, @JsonProperty("params") MessageSendParams params) {
@@ -41,36 +72,85 @@ public SendMessageRequest(@JsonProperty("jsonrpc") String jsonrpc, @JsonProperty
this.params = params;
}
+ /**
+ * Creates a new SendMessageRequest with simplified parameters.
+ * Uses the default JSON-RPC version ("2.0") and method ("message/send").
+ *
+ * @param id the request identifier (string, number, or null)
+ * @param params the message parameters containing the message content and configuration
+ */
public SendMessageRequest(Object id, MessageSendParams params) {
this(JSONRPC_VERSION, id, METHOD, params);
}
+ /**
+ * Builder class for constructing SendMessageRequest instances.
+ * Provides a fluent API for configuring request parameters.
+ */
public static class Builder {
+ /** The JSON-RPC protocol version */
private String jsonrpc;
+
+ /** The request identifier */
private Object id;
+
+ /** The JSON-RPC method name */
private String method;
+
+ /** The message parameters */
private MessageSendParams params;
+ /**
+ * Sets the JSON-RPC protocol version.
+ *
+ * @param jsonrpc the JSON-RPC version (should be "2.0")
+ * @return this builder instance for method chaining
+ */
public Builder jsonrpc(String jsonrpc) {
this.jsonrpc = jsonrpc;
return this;
}
+ /**
+ * Sets the request identifier.
+ *
+ * @param id the request identifier (string, number, or null)
+ * @return this builder instance for method chaining
+ */
public Builder id(Object id) {
this.id = id;
return this;
}
+ /**
+ * Sets the JSON-RPC method name.
+ *
+ * @param method the method name (should be "message/send")
+ * @return this builder instance for method chaining
+ */
public Builder method(String method) {
this.method = method;
return this;
}
+ /**
+ * Sets the message parameters.
+ *
+ * @param params the message parameters containing content and configuration
+ * @return this builder instance for method chaining
+ */
public Builder params(MessageSendParams params) {
this.params = params;
return this;
}
+ /**
+ * Builds and returns a new SendMessageRequest instance.
+ * If no ID is specified, generates a random UUID as the request identifier.
+ *
+ * @return a new SendMessageRequest with the configured parameters
+ * @throws IllegalArgumentException if required parameters are invalid
+ */
public SendMessageRequest build() {
if (id == null) {
id = UUID.randomUUID().toString();
diff --git a/spec/src/main/java/io/a2a/spec/SendMessageResponse.java b/spec/src/main/java/io/a2a/spec/SendMessageResponse.java
index 901beba90..319d4a0d2 100644
--- a/spec/src/main/java/io/a2a/spec/SendMessageResponse.java
+++ b/spec/src/main/java/io/a2a/spec/SendMessageResponse.java
@@ -9,22 +9,60 @@
import io.a2a.util.Assert;
/**
- * The response after receiving a send message request.
+ * Represents a JSON-RPC response for a message send request in the A2A protocol.
+ * This response is returned after an agent processes a SendMessageRequest,
+ * indicating the outcome of the message delivery attempt.
+ *
+ * The response follows the JSON-RPC 2.0 specification and contains either
+ * a successful result (EventKind) or an error. The result indicates the type
+ * of event that was generated as a result of sending the message.
+ *
+ * Possible outcomes:
+ *
+ * - Success: Contains an EventKind result indicating the message was processed
+ * - Error: Contains a JSONRPCError describing what went wrong
+ *
+ *
+ * The EventKind result provides information about how the agent handled
+ * the message, such as whether it was accepted, queued, or processed immediately.
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public final class SendMessageResponse extends JSONRPCResponse {
+ /**
+ * Creates a new SendMessageResponse with full parameter specification.
+ *
+ * @param jsonrpc the JSON-RPC protocol version (defaults to "2.0" if null)
+ * @param id the response identifier matching the original request ID
+ * @param result the successful result containing the event kind (null if error occurred)
+ * @param error the error information (null if successful)
+ * @throws IllegalArgumentException if id is not null, string, or integer
+ */
@JsonCreator
public SendMessageResponse(@JsonProperty("jsonrpc") String jsonrpc, @JsonProperty("id") Object id,
@JsonProperty("result") EventKind result, @JsonProperty("error") JSONRPCError error) {
super(jsonrpc, id, result, error, EventKind.class);
}
+ /**
+ * Creates a successful SendMessageResponse with the specified result.
+ * Uses the default JSON-RPC version ("2.0") and sets error to null.
+ *
+ * @param id the response identifier matching the original request ID
+ * @param result the successful result containing the event kind
+ */
public SendMessageResponse(Object id, EventKind result) {
this(null, id, result, null);
}
+ /**
+ * Creates an error SendMessageResponse with the specified error.
+ * Uses the default JSON-RPC version ("2.0") and sets result to null.
+ *
+ * @param id the response identifier matching the original request ID
+ * @param error the error information describing what went wrong
+ */
public SendMessageResponse(Object id, JSONRPCError error) {
this(null, id, null, error);
}
diff --git a/spec/src/main/java/io/a2a/spec/SendStreamingMessageRequest.java b/spec/src/main/java/io/a2a/spec/SendStreamingMessageRequest.java
index c4ebe8315..174fcea4f 100644
--- a/spec/src/main/java/io/a2a/spec/SendStreamingMessageRequest.java
+++ b/spec/src/main/java/io/a2a/spec/SendStreamingMessageRequest.java
@@ -11,14 +11,49 @@
import java.util.UUID;
/**
- * Used to initiate a task with streaming.
+ * Represents a JSON-RPC request for sending a streaming message to an agent in the A2A protocol.
+ * This request is used to initiate streaming message communication with an agent, allowing clients
+ * to send messages that expect a continuous stream of responses rather than a single response.
+ *
+ * The SendStreamingMessageRequest follows the JSON-RPC 2.0 specification and uses the
+ * "message/stream" method. It encapsulates message parameters and configuration options
+ * for streaming delivery and processing.
+ *
+ * Unlike SendMessageRequest which expects a single response, this streaming variant
+ * allows the agent to send multiple responses over time, making it suitable for:
+ *
+ * - Long-running tasks that provide progress updates
+ * - Interactive conversations with real-time responses
+ * - Tasks that generate incremental results
+ *
+ *
+ * Example usage:
+ *
+ * MessageSendParams params = new MessageSendParams.Builder()
+ * .message("Generate a long report")
+ * .build();
+ * SendStreamingMessageRequest request = new SendStreamingMessageRequest("stream-123", params);
+ *
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public final class SendStreamingMessageRequest extends StreamingJSONRPCRequest {
+ /** The JSON-RPC method name for streaming messages */
public static final String METHOD = "message/stream";
+ /**
+ * Creates a new SendStreamingMessageRequest with full parameter specification.
+ *
+ * @param jsonrpc the JSON-RPC protocol version (must be "2.0")
+ * @param id the request identifier (string, number, or null)
+ * @param method the JSON-RPC method name (must be "message/stream")
+ * @param params the message parameters containing the message content and configuration
+ * @throws IllegalArgumentException if jsonrpc is not "2.0"
+ * @throws IllegalArgumentException if method is not "message/stream"
+ * @throws IllegalArgumentException if params is null
+ * @throws IllegalArgumentException if id is not null, string, or integer
+ */
@JsonCreator
public SendStreamingMessageRequest(@JsonProperty("jsonrpc") String jsonrpc, @JsonProperty("id") Object id,
@JsonProperty("method") String method, @JsonProperty("params") MessageSendParams params) {
@@ -37,36 +72,85 @@ public SendStreamingMessageRequest(@JsonProperty("jsonrpc") String jsonrpc, @Jso
this.params = params;
}
+ /**
+ * Creates a new SendStreamingMessageRequest with simplified parameters.
+ * Uses the default JSON-RPC version ("2.0") and method ("message/stream").
+ *
+ * @param id the request identifier (string, number, or null)
+ * @param params the message parameters containing the message content and configuration
+ */
public SendStreamingMessageRequest(Object id, MessageSendParams params) {
this(null, id, METHOD, params);
}
+ /**
+ * Builder class for constructing SendStreamingMessageRequest instances.
+ * Provides a fluent API for configuring streaming request parameters.
+ */
public static class Builder {
+ /** The JSON-RPC protocol version */
private String jsonrpc;
+
+ /** The request identifier */
private Object id;
+
+ /** The JSON-RPC method name (defaults to "message/stream") */
private String method = METHOD;
+
+ /** The message parameters */
private MessageSendParams params;
+ /**
+ * Sets the JSON-RPC protocol version.
+ *
+ * @param jsonrpc the JSON-RPC version (should be "2.0")
+ * @return this builder instance for method chaining
+ */
public Builder jsonrpc(String jsonrpc) {
this.jsonrpc = jsonrpc;
return this;
}
+ /**
+ * Sets the request identifier.
+ *
+ * @param id the request identifier (string, number, or null)
+ * @return this builder instance for method chaining
+ */
public Builder id(Object id) {
this.id = id;
return this;
}
+ /**
+ * Sets the JSON-RPC method name.
+ *
+ * @param method the method name (should be "message/stream")
+ * @return this builder instance for method chaining
+ */
public Builder method(String method) {
this.method = method;
return this;
}
+ /**
+ * Sets the message parameters.
+ *
+ * @param params the message parameters containing content and configuration
+ * @return this builder instance for method chaining
+ */
public Builder params(MessageSendParams params) {
this.params = params;
return this;
}
+ /**
+ * Builds and returns a new SendStreamingMessageRequest instance.
+ * If no ID is specified, generates a random UUID as the request identifier.
+ *
+ * @return a new SendStreamingMessageRequest with the configured parameters
+ * @throws IllegalArgumentException if required parameters are invalid
+ */
public SendStreamingMessageRequest build() {
if (id == null) {
id = UUID.randomUUID().toString();
diff --git a/spec/src/main/java/io/a2a/spec/SendStreamingMessageResponse.java b/spec/src/main/java/io/a2a/spec/SendStreamingMessageResponse.java
index f3bcb9676..dad66b927 100644
--- a/spec/src/main/java/io/a2a/spec/SendStreamingMessageResponse.java
+++ b/spec/src/main/java/io/a2a/spec/SendStreamingMessageResponse.java
@@ -9,22 +9,64 @@
import io.a2a.util.Assert;
/**
- * The response after receiving a request to initiate a task with streaming.
+ * Represents a JSON-RPC response for a streaming message request in the A2A protocol.
+ * This response is returned after an agent processes a SendStreamingMessageRequest,
+ * indicating the outcome of the streaming message initiation.
+ *
+ * The response follows the JSON-RPC 2.0 specification and contains either
+ * a successful result (StreamingEventKind) or an error. The result indicates the type
+ * of streaming event that was generated as a result of initiating the streaming message.
+ *
+ * Unlike SendMessageResponse which contains a single EventKind, this streaming variant
+ * contains a StreamingEventKind that represents the initial response to starting a
+ * streaming conversation. Subsequent streaming responses will be delivered separately.
+ *
+ * Possible outcomes:
+ *
+ * - Success: Contains a StreamingEventKind result indicating streaming was initiated
+ * - Error: Contains a JSONRPCError describing what went wrong during initiation
+ *
+ *
+ * The StreamingEventKind result provides information about how the agent handled
+ * the streaming request, such as whether it was accepted and streaming has begun.
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public final class SendStreamingMessageResponse extends JSONRPCResponse {
+ /**
+ * Creates a new SendStreamingMessageResponse with full parameter specification.
+ *
+ * @param jsonrpc the JSON-RPC protocol version (defaults to "2.0" if null)
+ * @param id the response identifier matching the original request ID
+ * @param result the successful result containing the streaming event kind (null if error occurred)
+ * @param error the error information (null if successful)
+ * @throws IllegalArgumentException if id is not null, string, or integer
+ */
@JsonCreator
public SendStreamingMessageResponse(@JsonProperty("jsonrpc") String jsonrpc, @JsonProperty("id") Object id,
@JsonProperty("result") StreamingEventKind result, @JsonProperty("error") JSONRPCError error) {
super(jsonrpc, id, result, error, StreamingEventKind.class);
}
+ /**
+ * Creates a successful SendStreamingMessageResponse with the specified result.
+ * Uses the default JSON-RPC version ("2.0") and sets error to null.
+ *
+ * @param id the response identifier matching the original request ID
+ * @param result the successful result containing the streaming event kind
+ */
public SendStreamingMessageResponse(Object id, StreamingEventKind result) {
this(null, id, result, null);
}
+ /**
+ * Creates an error SendStreamingMessageResponse with the specified error.
+ * Uses the default JSON-RPC version ("2.0") and sets result to null.
+ *
+ * @param id the response identifier matching the original request ID
+ * @param error the error information describing what went wrong during streaming initiation
+ */
public SendStreamingMessageResponse(Object id, JSONRPCError error) {
this(null, id, null, error);
}
diff --git a/spec/src/main/java/io/a2a/spec/SetTaskPushNotificationConfigRequest.java b/spec/src/main/java/io/a2a/spec/SetTaskPushNotificationConfigRequest.java
index 7d53083a1..cfa50a693 100644
--- a/spec/src/main/java/io/a2a/spec/SetTaskPushNotificationConfigRequest.java
+++ b/spec/src/main/java/io/a2a/spec/SetTaskPushNotificationConfigRequest.java
@@ -12,14 +12,38 @@
import io.a2a.util.Assert;
/**
- * Used to set a task push notification request.
+ * Represents a JSON-RPC 2.0 request to configure push notification settings for a specific task.
+ * This request allows clients to set up push notification configurations that will be used
+ * to notify about task status changes, progress updates, or completion events.
+ *
+ * Push notification configurations enable real-time communication between the agent
+ * and external systems, allowing for immediate notification delivery when task events occur.
+ * This is particularly useful for long-running tasks where clients need to be notified
+ * of progress or completion without polling.
+ *
+ * The request follows the JSON-RPC 2.0 specification and uses the method
+ * "tasks/pushNotificationConfig/set" to identify this operation type.
+ *
+ * @see TaskPushNotificationConfig
+ * @see NonStreamingJSONRPCRequest
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public final class SetTaskPushNotificationConfigRequest extends NonStreamingJSONRPCRequest {
+ /** The JSON-RPC method name for setting task push notification configuration */
public static final String METHOD = "tasks/pushNotificationConfig/set";
+ /**
+ * Creates a new SetTaskPushNotificationConfigRequest with all JSON-RPC 2.0 fields.
+ * This constructor is primarily used by JSON deserialization.
+ *
+ * @param jsonrpc the JSON-RPC protocol version (must be "2.0")
+ * @param id the request identifier (string, number, or null)
+ * @param method the method name (must be "tasks/pushNotificationConfig/set")
+ * @param params the task push notification configuration parameters
+ * @throws IllegalArgumentException if jsonrpc version is invalid, method is incorrect, or params is null
+ */
@JsonCreator
public SetTaskPushNotificationConfigRequest(@JsonProperty("jsonrpc") String jsonrpc, @JsonProperty("id") Object id,
@JsonProperty("method") String method, @JsonProperty("params") TaskPushNotificationConfig params) {
@@ -38,36 +62,84 @@ public SetTaskPushNotificationConfigRequest(@JsonProperty("jsonrpc") String json
this.params = params;
}
+ /**
+ * Creates a new SetTaskPushNotificationConfigRequest with simplified parameters.
+ * The JSON-RPC version defaults to "2.0" and the method is automatically set.
+ *
+ * @param id the request identifier
+ * @param taskPushConfig the task push notification configuration
+ */
public SetTaskPushNotificationConfigRequest(String id, TaskPushNotificationConfig taskPushConfig) {
this(null, id, METHOD, taskPushConfig);
}
+ /**
+ * Builder class for constructing SetTaskPushNotificationConfigRequest instances.
+ * Provides a fluent API for setting request parameters with validation.
+ */
public static class Builder {
+ /** The JSON-RPC protocol version */
private String jsonrpc;
+
+ /** The request identifier */
private Object id;
+
+ /** The JSON-RPC method name */
private String method = METHOD;
+
+ /** The task push notification configuration parameters */
private TaskPushNotificationConfig params;
+ /**
+ * Sets the JSON-RPC protocol version.
+ *
+ * @param jsonrpc the JSON-RPC version (should be "2.0")
+ * @return this builder instance for method chaining
+ */
public SetTaskPushNotificationConfigRequest.Builder jsonrpc(String jsonrpc) {
this.jsonrpc = jsonrpc;
return this;
}
+ /**
+ * Sets the request identifier.
+ *
+ * @param id the request identifier (string, number, or null)
+ * @return this builder instance for method chaining
+ */
public SetTaskPushNotificationConfigRequest.Builder id(Object id) {
this.id = id;
return this;
}
+ /**
+ * Sets the JSON-RPC method name.
+ *
+ * @param method the method name (should be "tasks/pushNotificationConfig/set")
+ * @return this builder instance for method chaining
+ */
public SetTaskPushNotificationConfigRequest.Builder method(String method) {
this.method = method;
return this;
}
+ /**
+ * Sets the task push notification configuration parameters.
+ *
+ * @param params the task push notification configuration
+ * @return this builder instance for method chaining
+ */
public SetTaskPushNotificationConfigRequest.Builder params(TaskPushNotificationConfig params) {
this.params = params;
return this;
}
+ /**
+ * Builds and returns a new SetTaskPushNotificationConfigRequest instance.
+ * If no ID is provided, a random UUID will be generated.
+ *
+ * @return a new SetTaskPushNotificationConfigRequest with the configured parameters
+ */
public SetTaskPushNotificationConfigRequest build() {
if (id == null) {
id = UUID.randomUUID().toString();
diff --git a/spec/src/main/java/io/a2a/spec/SetTaskPushNotificationConfigResponse.java b/spec/src/main/java/io/a2a/spec/SetTaskPushNotificationConfigResponse.java
index c40f18f18..0fc3a304f 100644
--- a/spec/src/main/java/io/a2a/spec/SetTaskPushNotificationConfigResponse.java
+++ b/spec/src/main/java/io/a2a/spec/SetTaskPushNotificationConfigResponse.java
@@ -6,12 +6,36 @@
import com.fasterxml.jackson.annotation.JsonProperty;
/**
- * The response after receiving a set task push notification request.
+ * Represents a JSON-RPC 2.0 response to a task push notification configuration request.
+ * This response is sent back to the client after processing a SetTaskPushNotificationConfigRequest,
+ * indicating whether the push notification configuration was successfully set or if an error occurred.
+ *
+ * The response can contain either:
+ *
+ * - A successful result with the configured TaskPushNotificationConfig
+ * - An error object describing what went wrong during the configuration process
+ *
+ *
+ * This follows the JSON-RPC 2.0 specification for response messages, ensuring
+ * compatibility with standard JSON-RPC clients and tooling.
+ *
+ * @see SetTaskPushNotificationConfigRequest
+ * @see TaskPushNotificationConfig
+ * @see JSONRPCResponse
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public final class SetTaskPushNotificationConfigResponse extends JSONRPCResponse {
+ /**
+ * Creates a new SetTaskPushNotificationConfigResponse with all JSON-RPC 2.0 fields.
+ * This constructor is primarily used by JSON deserialization.
+ *
+ * @param jsonrpc the JSON-RPC protocol version (should be "2.0")
+ * @param id the request identifier that matches the original request
+ * @param result the task push notification configuration result (null if error occurred)
+ * @param error the error object (null if successful)
+ */
@JsonCreator
public SetTaskPushNotificationConfigResponse(@JsonProperty("jsonrpc") String jsonrpc, @JsonProperty("id") Object id,
@JsonProperty("result") TaskPushNotificationConfig result,
@@ -19,10 +43,24 @@ public SetTaskPushNotificationConfigResponse(@JsonProperty("jsonrpc") String jso
super(jsonrpc, id, result, error, TaskPushNotificationConfig.class);
}
+ /**
+ * Creates an error response for a task push notification configuration request.
+ * The JSON-RPC version defaults to "2.0" and the result is set to null.
+ *
+ * @param id the request identifier that matches the original request
+ * @param error the error object describing what went wrong
+ */
public SetTaskPushNotificationConfigResponse(Object id, JSONRPCError error) {
this(null, id, null, error);
}
+ /**
+ * Creates a successful response for a task push notification configuration request.
+ * The JSON-RPC version defaults to "2.0" and the error is set to null.
+ *
+ * @param id the request identifier that matches the original request
+ * @param result the successfully configured task push notification configuration
+ */
public SetTaskPushNotificationConfigResponse(Object id, TaskPushNotificationConfig result) {
this(null, id, result, null);
}
diff --git a/spec/src/main/java/io/a2a/spec/StreamingEventKind.java b/spec/src/main/java/io/a2a/spec/StreamingEventKind.java
index a7a6b6232..877347c90 100644
--- a/spec/src/main/java/io/a2a/spec/StreamingEventKind.java
+++ b/spec/src/main/java/io/a2a/spec/StreamingEventKind.java
@@ -8,6 +8,28 @@
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
+/**
+ * Sealed interface for events that can be streamed in the A2A protocol.
+ *
+ * This interface extends {@link Event} and provides polymorphic JSON serialization/deserialization
+ * support for streaming events in the A2A framework. The "kind" property is used as a discriminator
+ * to determine the concrete type during JSON processing in streaming contexts.
+ *
+ * Currently supported streaming event kinds include:
+ *
+ * - {@code "task"} - Represents a {@link Task} object
+ * - {@code "message"} - Represents a {@link Message} object
+ * - {@code "status-update"} - Represents a {@link TaskStatusUpdateEvent}
+ * - {@code "artifact-update"} - Represents a {@link TaskArtifactUpdateEvent}
+ *
+ *
+ * The sealed interface restricts implementations to the explicitly permitted classes,
+ * ensuring type safety and enabling exhaustive pattern matching in switch expressions.
+ *
+ * The Jackson annotations configure automatic type resolution based on the "kind" field
+ * in JSON data, enabling seamless conversion between JSON and the appropriate Java types
+ * during streaming operations.
+ */
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
@@ -22,5 +44,14 @@
})
public sealed interface StreamingEventKind extends Event permits Task, Message, TaskStatusUpdateEvent, TaskArtifactUpdateEvent {
+ /**
+ * Returns the kind/type identifier for this streaming event.
+ *
+ * This method provides the discriminator value used for JSON serialization
+ * and type resolution in streaming contexts. The returned string should match
+ * one of the values defined in the {@link JsonSubTypes} annotation.
+ *
+ * @return the kind identifier (e.g., "task", "message", "status-update", "artifact-update")
+ */
String getKind();
}
diff --git a/spec/src/main/java/io/a2a/spec/StreamingJSONRPCRequest.java b/spec/src/main/java/io/a2a/spec/StreamingJSONRPCRequest.java
index 7642c41d2..66a3eff03 100644
--- a/spec/src/main/java/io/a2a/spec/StreamingJSONRPCRequest.java
+++ b/spec/src/main/java/io/a2a/spec/StreamingJSONRPCRequest.java
@@ -5,7 +5,30 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
/**
- * Represents a streaming JSON-RPC request.
+ * Abstract base class for streaming JSON-RPC 2.0 requests in the A2A protocol.
+ * Streaming requests are designed to handle operations that may produce continuous
+ * or real-time data streams, such as task resubscription or streaming message sending.
+ *
+ * This class extends the base JSONRPCRequest and provides specialized handling
+ * for streaming operations. Streaming requests typically involve:
+ *
+ * - Long-running operations that produce incremental results
+ * - Real-time data transmission
+ * - Continuous monitoring or subscription-based operations
+ *
+ *
+ * The class is sealed and only permits specific implementations:
+ * TaskResubscriptionRequest and SendStreamingMessageRequest, ensuring type safety
+ * and controlled extensibility.
+ *
+ * Deserialization is handled by the StreamingJSONRPCRequestDeserializer to
+ * properly route incoming JSON to the correct concrete implementation.
+ *
+ * @param the type of the request parameters
+ * @see JSONRPCRequest
+ * @see TaskResubscriptionRequest
+ * @see SendStreamingMessageRequest
+ * @see StreamingJSONRPCRequestDeserializer
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
diff --git a/spec/src/main/java/io/a2a/spec/StreamingJSONRPCRequestDeserializer.java b/spec/src/main/java/io/a2a/spec/StreamingJSONRPCRequestDeserializer.java
index 236ad547a..bb752b996 100644
--- a/spec/src/main/java/io/a2a/spec/StreamingJSONRPCRequestDeserializer.java
+++ b/spec/src/main/java/io/a2a/spec/StreamingJSONRPCRequestDeserializer.java
@@ -7,16 +7,56 @@
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
+/**
+ * Custom Jackson deserializer for streaming JSON-RPC 2.0 requests in the A2A protocol.
+ * This deserializer examines the "method" field of incoming JSON to determine which
+ * specific StreamingJSONRPCRequest subclass should be instantiated.
+ *
+ * The deserializer supports the following streaming request types:
+ *
+ * - TaskResubscriptionRequest - for resubscribing to task updates
+ * - SendStreamingMessageRequest - for sending streaming messages
+ *
+ *
+ * The deserialization process validates the JSON-RPC structure, extracts the method name,
+ * and routes to the appropriate concrete class constructor. If an unsupported method is
+ * encountered, a MethodNotFoundJsonMappingException is thrown.
+ *
+ * @param the generic type parameter (not used in this implementation)
+ * @see StreamingJSONRPCRequest
+ * @see JSONRPCRequestDeserializerBase
+ * @see TaskResubscriptionRequest
+ * @see SendStreamingMessageRequest
+ */
public class StreamingJSONRPCRequestDeserializer extends JSONRPCRequestDeserializerBase> {
+ /**
+ * Default constructor for the streaming JSON-RPC request deserializer.
+ */
public StreamingJSONRPCRequestDeserializer() {
this(null);
}
+ /**
+ * Constructor with value class parameter.
+ *
+ * @param vc the value class (typically not used)
+ */
public StreamingJSONRPCRequestDeserializer(Class> vc) {
super(vc);
}
+ /**
+ * Deserializes JSON into the appropriate StreamingJSONRPCRequest subclass.
+ * The method field is used to determine which specific request type to create.
+ *
+ * @param jsonParser the JSON parser containing the request data
+ * @param context the deserialization context
+ * @return the appropriate StreamingJSONRPCRequest subclass instance
+ * @throws IOException if JSON parsing fails
+ * @throws JsonProcessingException if JSON processing fails
+ * @throws MethodNotFoundJsonMappingException if the method is not supported
+ */
@Override
public StreamingJSONRPCRequest> deserialize(JsonParser jsonParser, DeserializationContext context)
throws IOException, JsonProcessingException {
diff --git a/spec/src/main/java/io/a2a/spec/StringJsonrpcId.java b/spec/src/main/java/io/a2a/spec/StringJsonrpcId.java
index 74a28272f..65cad17af 100644
--- a/spec/src/main/java/io/a2a/spec/StringJsonrpcId.java
+++ b/spec/src/main/java/io/a2a/spec/StringJsonrpcId.java
@@ -1,4 +1,24 @@
package io.a2a.spec;
+/**
+ * Utility class for handling string-based JSON-RPC request identifiers.
+ * This class provides functionality for working with string IDs in JSON-RPC 2.0 requests
+ * and responses within the A2A protocol.
+ *
+ * JSON-RPC 2.0 allows request identifiers to be strings, numbers, or null.
+ * This class specifically handles the string variant, which is commonly used
+ * for human-readable or UUID-based request tracking.
+ *
+ * String IDs are particularly useful for:
+ *
+ * - Debugging and logging purposes
+ * - Correlation with external systems
+ * - UUID-based request tracking
+ * - Human-readable request identification
+ *
+ *
+ * @see JSONRPCRequest
+ * @see JSONRPCResponse
+ */
public class StringJsonrpcId {
}
diff --git a/spec/src/main/java/io/a2a/spec/Task.java b/spec/src/main/java/io/a2a/spec/Task.java
index 86c92473e..bb29894c8 100644
--- a/spec/src/main/java/io/a2a/spec/Task.java
+++ b/spec/src/main/java/io/a2a/spec/Task.java
@@ -11,7 +11,9 @@
import io.a2a.util.Assert;
/**
- * A central unit of work.
+ * Represents a task in the A2A protocol.
+ * A task encapsulates a unit of work with its current state, artifacts, message history, and metadata.
+ * Tasks are the primary way to track and manage work progress in agent-to-agent communication.
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -20,19 +22,72 @@ public final class Task implements EventKind, StreamingEventKind {
public static final TypeReference TYPE_REFERENCE = new TypeReference<>() {};
public static final String TASK = "task";
+
+ /**
+ * Unique identifier for this task.
+ */
private final String id;
+
+ /**
+ * Identifier for the conversation context this task belongs to.
+ */
private final String contextId;
+
+ /**
+ * Current status of the task (e.g., pending, in_progress, completed, failed).
+ */
private final TaskStatus status;
+
+ /**
+ * List of artifacts produced or associated with this task.
+ * Artifacts represent the outputs or deliverables of the task.
+ */
private final List artifacts;
+
+ /**
+ * Message history associated with this task.
+ * Contains all messages that are part of this task's execution.
+ */
private final List history;
+
+ /**
+ * Additional metadata associated with this task.
+ * Can contain custom properties specific to the implementation or task type.
+ */
private final Map metadata;
+
+ /**
+ * The kind/type of this object, always "task" for Task instances.
+ */
private final String kind;
+ /**
+ * Constructs a new Task with the specified properties.
+ * The kind is automatically set to "task".
+ *
+ * @param id unique identifier for this task
+ * @param contextId identifier for the conversation context
+ * @param status current status of the task
+ * @param artifacts list of artifacts associated with this task
+ * @param history message history for this task
+ * @param metadata additional metadata for this task
+ */
public Task(String id, String contextId, TaskStatus status, List artifacts,
List history, Map metadata) {
this(id, contextId, status, artifacts, history, metadata, TASK);
}
+ /**
+ * Constructs a new Task with the specified properties and kind.
+ *
+ * @param id unique identifier for this task
+ * @param contextId identifier for the conversation context
+ * @param status current status of the task
+ * @param artifacts list of artifacts associated with this task
+ * @param history message history for this task
+ * @param metadata additional metadata for this task
+ * @param kind the kind/type of this object, must be "task"
+ */
@JsonCreator
public Task(@JsonProperty("id") String id, @JsonProperty("contextId") String contextId, @JsonProperty("status") TaskStatus status,
@JsonProperty("artifacts") List artifacts, @JsonProperty("history") List history,
@@ -53,30 +108,65 @@ public Task(@JsonProperty("id") String id, @JsonProperty("contextId") String con
this.kind = kind;
}
+ /**
+ * Returns the unique identifier for this task.
+ *
+ * @return the task ID
+ */
public String getId() {
return id;
}
+ /**
+ * Returns the identifier for the conversation context this task belongs to.
+ *
+ * @return the context ID
+ */
public String getContextId() {
return contextId;
}
+ /**
+ * Returns the current status of the task.
+ *
+ * @return the task status
+ */
public TaskStatus getStatus() {
return status;
}
+ /**
+ * Returns the list of artifacts associated with this task.
+ *
+ * @return the artifacts list
+ */
public List getArtifacts() {
return artifacts;
}
+ /**
+ * Returns the message history for this task.
+ *
+ * @return the message history
+ */
public List getHistory() {
return history;
}
+ /**
+ * Returns the additional metadata associated with this task.
+ *
+ * @return the metadata map
+ */
public Map getMetadata() {
return metadata;
}
+ /**
+ * Returns the kind/type of this object.
+ *
+ * @return the kind string, always "task" for Task instances
+ */
public String getKind() {
return kind;
}
@@ -89,10 +179,18 @@ public static class Builder {
private List history;
private Map metadata;
+ /**
+ * Creates a new empty Builder.
+ */
public Builder() {
}
+ /**
+ * Creates a new Builder initialized with values from an existing Task.
+ *
+ * @param task the task to copy values from
+ */
public Builder(Task task) {
id = task.id;
contextId = task.contextId;
@@ -103,41 +201,88 @@ public Builder(Task task) {
}
+ /**
+ * Sets the task ID.
+ *
+ * @param id the task ID
+ * @return this builder
+ */
public Builder id(String id) {
this.id = id;
return this;
}
+ /**
+ * Sets the context ID.
+ *
+ * @param contextId the context ID
+ * @return this builder
+ */
public Builder contextId(String contextId) {
this.contextId = contextId;
return this;
}
+ /**
+ * Sets the task status.
+ *
+ * @param status the task status
+ * @return this builder
+ */
public Builder status(TaskStatus status) {
this.status = status;
return this;
}
+ /**
+ * Sets the artifacts list.
+ *
+ * @param artifacts the artifacts list
+ * @return this builder
+ */
public Builder artifacts(List artifacts) {
this.artifacts = artifacts;
return this;
}
+ /**
+ * Sets the message history.
+ *
+ * @param history the message history
+ * @return this builder
+ */
public Builder history(List history) {
this.history = history;
return this;
}
+ /**
+ * Sets the message history from varargs.
+ *
+ * @param history the messages
+ * @return this builder
+ */
public Builder history(Message... history) {
this.history = List.of(history);
return this;
}
+ /**
+ * Sets the metadata.
+ *
+ * @param metadata the metadata map
+ * @return this builder
+ */
public Builder metadata(Map metadata) {
this.metadata = metadata;
return this;
}
+ /**
+ * Builds a new Task instance with the configured properties.
+ *
+ * @return a new Task instance
+ */
public Task build() {
return new Task(id, contextId, status, artifacts, history, metadata);
}
diff --git a/spec/src/main/java/io/a2a/spec/TaskArtifactUpdateEvent.java b/spec/src/main/java/io/a2a/spec/TaskArtifactUpdateEvent.java
index 49485577b..0a1b4773a 100644
--- a/spec/src/main/java/io/a2a/spec/TaskArtifactUpdateEvent.java
+++ b/spec/src/main/java/io/a2a/spec/TaskArtifactUpdateEvent.java
@@ -9,25 +9,85 @@
import io.a2a.util.Assert;
/**
- * A task artifact update event.
+ * Represents a task artifact update event in the A2A protocol.
+ *
+ * This event is emitted when a task produces or updates an artifact during execution,
+ * providing real-time notifications about artifact creation, modification, or completion.
+ * It implements both {@link EventKind} and {@link StreamingEventKind} to support
+ * different event processing patterns in the A2A framework.
+ *
+ * The event contains information about which task produced the artifact, the artifact
+ * itself, the context it belongs to, whether this is an append operation, whether this
+ * is the last chunk of a streaming artifact, and any additional metadata.
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public final class TaskArtifactUpdateEvent implements EventKind, StreamingEventKind {
public static final String ARTIFACT_UPDATE = "artifact-update";
+ /**
+ * The unique identifier of the task that produced or updated the artifact.
+ */
private final String taskId;
+
+ /**
+ * Indicates whether this artifact update should be appended to existing content.
+ * If true, the artifact content should be appended; if false or null, it should replace existing content.
+ */
private final Boolean append;
+
+ /**
+ * Indicates whether this is the last chunk of a streaming artifact.
+ * Used for streaming scenarios where artifacts are sent in multiple chunks.
+ */
private final Boolean lastChunk;
+
+ /**
+ * The artifact that was produced or updated by the task.
+ */
private final Artifact artifact;
+
+ /**
+ * The identifier of the context/conversation this task belongs to.
+ */
private final String contextId;
+
+ /**
+ * Additional metadata associated with this artifact update.
+ * Can contain implementation-specific information about the artifact update.
+ */
private final Map metadata;
+
+ /**
+ * The kind/type of this event, always "artifact-update" for TaskArtifactUpdateEvent instances.
+ */
private final String kind;
+ /**
+ * Constructs a new TaskArtifactUpdateEvent with the specified properties.
+ *
+ * @param taskId the unique identifier of the task that produced the artifact
+ * @param artifact the artifact that was produced or updated
+ * @param contextId the identifier of the context/conversation this task belongs to
+ * @param append whether this artifact update should be appended to existing content
+ * @param lastChunk whether this is the last chunk of a streaming artifact
+ * @param metadata additional metadata associated with this artifact update
+ */
public TaskArtifactUpdateEvent(String taskId, Artifact artifact, String contextId, Boolean append, Boolean lastChunk, Map metadata) {
this(taskId, artifact, contextId, append, lastChunk, metadata, ARTIFACT_UPDATE);
}
+ /**
+ * JSON constructor for creating TaskArtifactUpdateEvent instances from JSON data.
+ *
+ * @param taskId the unique identifier of the task that produced the artifact
+ * @param artifact the artifact that was produced or updated
+ * @param contextId the identifier of the context/conversation this task belongs to
+ * @param append whether this artifact update should be appended to existing content
+ * @param lastChunk whether this is the last chunk of a streaming artifact
+ * @param metadata additional metadata associated with this artifact update
+ * @param kind the kind/type of this event
+ */
@JsonCreator
public TaskArtifactUpdateEvent(@JsonProperty("taskId") String taskId, @JsonProperty("artifact") Artifact artifact,
@JsonProperty("contextId") String contextId,
@@ -51,35 +111,73 @@ public TaskArtifactUpdateEvent(@JsonProperty("taskId") String taskId, @JsonPrope
this.kind = kind;
}
+ /**
+ * Gets the unique identifier of the task that produced or updated the artifact.
+ *
+ * @return the task ID
+ */
public String getTaskId() {
return taskId;
}
+ /**
+ * Gets the artifact that was produced or updated by the task.
+ *
+ * @return the artifact
+ */
public Artifact getArtifact() {
return artifact;
}
+ /**
+ * Gets the identifier of the context/conversation this task belongs to.
+ *
+ * @return the context ID
+ */
public String getContextId() {
return contextId;
}
+ /**
+ * Indicates whether this artifact update should be appended to existing content.
+ *
+ * @return true if content should be appended, false if it should replace, null if not specified
+ */
public Boolean isAppend() {
return append;
}
+ /**
+ * Indicates whether this is the last chunk of a streaming artifact.
+ *
+ * @return true if this is the last chunk, false if more chunks are expected, null if not applicable
+ */
public Boolean isLastChunk() {
return lastChunk;
}
+ /**
+ * Gets the additional metadata associated with this artifact update.
+ *
+ * @return the metadata map
+ */
public Map getMetadata() {
return metadata;
}
+ /**
+ * Gets the kind/type of this event.
+ *
+ * @return the event kind, always "artifact-update" for TaskArtifactUpdateEvent instances
+ */
@Override
public String getKind() {
return kind;
}
+ /**
+ * Builder class for constructing {@link TaskArtifactUpdateEvent} instances.
+ */
public static class Builder {
private String taskId;
@@ -89,37 +187,77 @@ public static class Builder {
private Boolean lastChunk;
private Map metadata;
+ /**
+ * Sets the unique identifier of the task that produced or updated the artifact.
+ *
+ * @param taskId the task ID
+ * @return this builder instance
+ */
public Builder taskId(String taskId) {
this.taskId = taskId;
return this;
}
+ /**
+ * Sets the artifact that was produced or updated by the task.
+ *
+ * @param artifact the artifact
+ * @return this builder instance
+ */
public Builder artifact(Artifact artifact) {
this.artifact = artifact;
return this;
}
+ /**
+ * Sets the identifier of the context/conversation this task belongs to.
+ *
+ * @param contextId the context ID
+ * @return this builder instance
+ */
public Builder contextId(String contextId) {
this.contextId = contextId;
return this;
}
+ /**
+ * Sets whether this artifact update should be appended to existing content.
+ *
+ * @param append true if content should be appended, false if it should replace, null if not specified
+ * @return this builder instance
+ */
public Builder append(Boolean append) {
this.append = append;
return this;
}
+ /**
+ * Sets whether this is the last chunk of a streaming artifact.
+ *
+ * @param lastChunk true if this is the last chunk, false if more chunks are expected, null if not applicable
+ * @return this builder instance
+ */
public Builder lastChunk(Boolean lastChunk) {
this.lastChunk = lastChunk;
return this;
}
-
+ /**
+ * Sets the additional metadata associated with this artifact update.
+ *
+ * @param metadata the metadata map
+ * @return this builder instance
+ */
public Builder metadata(Map metadata) {
this.metadata = metadata;
return this;
}
+ /**
+ * Builds and returns a new {@link TaskArtifactUpdateEvent} instance with the configured properties.
+ *
+ * @return a new TaskArtifactUpdateEvent instance
+ */
public TaskArtifactUpdateEvent build() {
return new TaskArtifactUpdateEvent(taskId, artifact, contextId, append, lastChunk, metadata);
}
diff --git a/spec/src/main/java/io/a2a/spec/TaskIdParams.java b/spec/src/main/java/io/a2a/spec/TaskIdParams.java
index 816550eb9..41bb4270b 100644
--- a/spec/src/main/java/io/a2a/spec/TaskIdParams.java
+++ b/spec/src/main/java/io/a2a/spec/TaskIdParams.java
@@ -7,16 +7,39 @@
import io.a2a.util.Assert;
/**
- * Task id parameters.
+ * Represents task identifier parameters in the A2A protocol.
+ *
+ * This record encapsulates a task ID along with optional metadata.
+ * It is commonly used in API requests and responses that need to
+ * reference a specific task, such as task queries, updates, or
+ * status requests.
+ *
+ *
+ * @param id the unique identifier of the task
+ * @param metadata optional metadata associated with the task identifier
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public record TaskIdParams(String id, Map metadata) {
+ /**
+ * Compact constructor that validates the task ID parameters.
+ *
+ * This constructor ensures that the task ID is not null, as it is
+ * required to uniquely identify the task.
+ *
+ *
+ * @throws IllegalArgumentException if id is null
+ */
public TaskIdParams {
Assert.checkNotNullParam("id", id);
}
+ /**
+ * Convenience constructor for creating TaskIdParams with only an ID.
+ *
+ * @param id the unique identifier of the task
+ */
public TaskIdParams(String id) {
this(id, null);
}
diff --git a/spec/src/main/java/io/a2a/spec/TaskNotCancelableError.java b/spec/src/main/java/io/a2a/spec/TaskNotCancelableError.java
index aa40a81d3..ceedd1d38 100644
--- a/spec/src/main/java/io/a2a/spec/TaskNotCancelableError.java
+++ b/spec/src/main/java/io/a2a/spec/TaskNotCancelableError.java
@@ -7,16 +7,49 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * Represents a JSON-RPC 2.0 error indicating that a task cannot be canceled.
+ * This error is returned when a client attempts to cancel a task that is not
+ * in a cancelable state, such as tasks that have already completed, failed,
+ * or are in a critical phase where cancellation is not permitted.
+ *
+ * Common scenarios where this error occurs:
+ *
+ * - Task has already completed successfully
+ * - Task has already failed or been canceled
+ * - Task is in a critical execution phase where cancellation would cause data corruption
+ * - Task type does not support cancellation by design
+ *
+ *
+ * The error follows JSON-RPC 2.0 error object specification with a default
+ * error code of -32002 and a descriptive message. Additional context can be
+ * provided through the data field.
+ *
+ * @see JSONRPCError
+ */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public class TaskNotCancelableError extends JSONRPCError {
+ /** Default error code for task not cancelable errors */
public final static Integer DEFAULT_CODE = -32002;
+ /**
+ * Creates a TaskNotCancelableError with default values.
+ * Uses the default error code and message.
+ */
public TaskNotCancelableError() {
this(null, null, null);
}
+ /**
+ * Creates a TaskNotCancelableError with custom values.
+ * Any null parameters will be replaced with default values.
+ *
+ * @param code the error code (defaults to -32002 if null)
+ * @param message the error message (defaults to "Task cannot be canceled" if null)
+ * @param data additional error data (can be null)
+ */
@JsonCreator
public TaskNotCancelableError(
@JsonProperty("code") Integer code,
diff --git a/spec/src/main/java/io/a2a/spec/TaskNotFoundError.java b/spec/src/main/java/io/a2a/spec/TaskNotFoundError.java
index 26ee264e3..743b8e201 100644
--- a/spec/src/main/java/io/a2a/spec/TaskNotFoundError.java
+++ b/spec/src/main/java/io/a2a/spec/TaskNotFoundError.java
@@ -7,18 +7,49 @@
import static io.a2a.util.Utils.defaultIfNull;
+/**
+ * Represents a JSON-RPC 2.0 error indicating that a requested task was not found.
+ * This error is returned when a client attempts to access, modify, or query a task
+ * that does not exist in the agent's task registry or has been removed.
+ *
+ * Common scenarios where this error occurs:
+ *
+ * - Task ID does not exist in the system
+ * - Task has been deleted or expired
+ * - Task ID format is invalid or malformed
+ * - Client lacks permission to access the specified task
+ *
+ *
+ * The error follows JSON-RPC 2.0 error object specification with a default
+ * error code of -32001 and a descriptive message. Additional context such as
+ * the invalid task ID can be provided through the data field.
+ *
+ * @see JSONRPCError
+ */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public class TaskNotFoundError extends JSONRPCError {
+ /** Default error code for task not found errors */
public final static Integer DEFAULT_CODE = -32001;
+ /**
+ * Creates a TaskNotFoundError with default values.
+ * Uses the default error code and message.
+ */
public TaskNotFoundError() {
this(null, null, null);
}
+ /**
+ * Creates a TaskNotFoundError with custom values.
+ * Any null parameters will be replaced with default values.
+ *
+ * @param code the error code (defaults to -32001 if null)
+ * @param message the error message (defaults to "Task not found" if null)
+ * @param data additional error data, such as the invalid task ID (can be null)
+ */
@JsonCreator
-
public TaskNotFoundError(
@JsonProperty("code") Integer code,
@JsonProperty("message") String message,
diff --git a/spec/src/main/java/io/a2a/spec/TaskPushNotificationConfig.java b/spec/src/main/java/io/a2a/spec/TaskPushNotificationConfig.java
index 0e4163212..5b358ec1f 100644
--- a/spec/src/main/java/io/a2a/spec/TaskPushNotificationConfig.java
+++ b/spec/src/main/java/io/a2a/spec/TaskPushNotificationConfig.java
@@ -5,12 +5,37 @@
import io.a2a.util.Assert;
/**
- * Task push notification configuration.
+ * Represents the configuration for push notifications associated with a specific task.
+ * This record binds a task identifier to its corresponding push notification settings,
+ * enabling the agent to send real-time notifications about task status changes,
+ * progress updates, or completion events.
+ *
+ * Task push notification configurations are essential for:
+ *
+ * - Real-time task status monitoring
+ * - Progress tracking for long-running operations
+ * - Immediate notification of task completion or failure
+ * - Integration with external monitoring and alerting systems
+ *
+ *
+ * The configuration ensures that clients can receive timely updates about
+ * task execution without the need for continuous polling, improving efficiency
+ * and user experience.
+ *
+ * @param taskId the unique identifier of the task to monitor
+ * @param pushNotificationConfig the push notification configuration settings
+ * @see PushNotificationConfig
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public record TaskPushNotificationConfig(String taskId, PushNotificationConfig pushNotificationConfig) {
+ /**
+ * Compact constructor that validates the required parameters.
+ * Ensures that both taskId and pushNotificationConfig are not null.
+ *
+ * @throws IllegalArgumentException if taskId or pushNotificationConfig is null
+ */
public TaskPushNotificationConfig {
Assert.checkNotNullParam("taskId", taskId);
Assert.checkNotNullParam("pushNotificationConfig", pushNotificationConfig);
diff --git a/spec/src/main/java/io/a2a/spec/TaskQueryParams.java b/spec/src/main/java/io/a2a/spec/TaskQueryParams.java
index 2587e5fb5..895e097f0 100644
--- a/spec/src/main/java/io/a2a/spec/TaskQueryParams.java
+++ b/spec/src/main/java/io/a2a/spec/TaskQueryParams.java
@@ -7,16 +7,30 @@
import io.a2a.util.Assert;
/**
- * Task query parameters.
+ * Represents parameters for querying task information in the A2A protocol.
+ *
+ * This record encapsulates the parameters needed to query a specific task,
+ * including options to control the amount of historical data returned and
+ * additional metadata for the query.
+ *
*
- * @param id the ID for the task to be queried
- * @param historyLength the maximum number of items of history for the task to include in the response
- * @param metadata additional properties
+ * @param id the unique identifier of the task to be queried
+ * @param historyLength the maximum number of historical items to include in the response (null for default)
+ * @param metadata additional properties and metadata for the query
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public record TaskQueryParams(String id, Integer historyLength, Map metadata) {
+ /**
+ * Compact constructor that validates the task query parameters.
+ *
+ * This constructor ensures that the task ID is not null and that
+ * the history length, if specified, is not negative.
+ *
+ *
+ * @throws IllegalArgumentException if id is null or historyLength is negative
+ */
public TaskQueryParams {
Assert.checkNotNullParam("id", id);
if (historyLength != null && historyLength < 0) {
@@ -24,10 +38,21 @@ public record TaskQueryParams(String id, Integer historyLength, MapTask resubscription is typically used in scenarios such as:
+ *
+ * - Reconnecting after a network disconnection
+ * - Resuming monitoring of long-running tasks
+ * - Re-establishing event streams after client restart
+ * - Switching between different monitoring configurations
+ *
+ *
+ * As a streaming request, this operation establishes a persistent connection
+ * that delivers continuous updates until the task completes or the subscription
+ * is explicitly canceled. The request follows the JSON-RPC 2.0 specification
+ * and uses the method "tasks/resubscribe".
+ *
+ * @see StreamingJSONRPCRequest
+ * @see TaskIdParams
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public final class TaskResubscriptionRequest extends StreamingJSONRPCRequest {
+ /** The JSON-RPC method name for task resubscription requests */
public static final String METHOD = "tasks/resubscribe";
+ /**
+ * Creates a new TaskResubscriptionRequest with all JSON-RPC 2.0 fields.
+ * This constructor is primarily used by JSON deserialization.
+ *
+ * @param jsonrpc the JSON-RPC protocol version (must be "2.0")
+ * @param id the request identifier (string, number, or null; auto-generated if null)
+ * @param method the method name (must be "tasks/resubscribe")
+ * @param params the task ID parameters specifying which task to resubscribe to
+ * @throws IllegalArgumentException if jsonrpc version is invalid, method is incorrect, or params is null
+ */
@JsonCreator
public TaskResubscriptionRequest(@JsonProperty("jsonrpc") String jsonrpc, @JsonProperty("id") Object id,
@JsonProperty("method") String method, @JsonProperty("params") TaskIdParams params) {
@@ -36,36 +65,84 @@ public TaskResubscriptionRequest(@JsonProperty("jsonrpc") String jsonrpc, @JsonP
this.params = params;
}
+ /**
+ * Creates a new TaskResubscriptionRequest with simplified parameters.
+ * The JSON-RPC version defaults to "2.0" and the method is automatically set.
+ *
+ * @param id the request identifier
+ * @param params the task ID parameters specifying which task to resubscribe to
+ */
public TaskResubscriptionRequest(Object id, TaskIdParams params) {
this(null, id, METHOD, params);
}
+ /**
+ * Builder class for constructing TaskResubscriptionRequest instances.
+ * Provides a fluent API for setting request parameters with validation.
+ */
public static class Builder {
+ /** The JSON-RPC protocol version */
private String jsonrpc;
+
+ /** The request identifier */
private Object id;
+
+ /** The JSON-RPC method name */
private String method = METHOD;
+
+ /** The task ID parameters */
private TaskIdParams params;
+ /**
+ * Sets the JSON-RPC protocol version.
+ *
+ * @param jsonrpc the JSON-RPC version (should be "2.0")
+ * @return this builder instance for method chaining
+ */
public TaskResubscriptionRequest.Builder jsonrpc(String jsonrpc) {
this.jsonrpc = jsonrpc;
return this;
}
+ /**
+ * Sets the request identifier.
+ *
+ * @param id the request identifier (string, number, or null)
+ * @return this builder instance for method chaining
+ */
public TaskResubscriptionRequest.Builder id(Object id) {
this.id = id;
return this;
}
+ /**
+ * Sets the JSON-RPC method name.
+ *
+ * @param method the method name (should be "tasks/resubscribe")
+ * @return this builder instance for method chaining
+ */
public TaskResubscriptionRequest.Builder method(String method) {
this.method = method;
return this;
}
+ /**
+ * Sets the task ID parameters.
+ *
+ * @param params the task ID parameters specifying which task to resubscribe to
+ * @return this builder instance for method chaining
+ */
public TaskResubscriptionRequest.Builder params(TaskIdParams params) {
this.params = params;
return this;
}
+ /**
+ * Builds and returns a new TaskResubscriptionRequest instance.
+ * If no ID is provided, a random UUID will be generated.
+ *
+ * @return a new TaskResubscriptionRequest with the configured parameters
+ */
public TaskResubscriptionRequest build() {
if (id == null) {
id = UUID.randomUUID().toString();
diff --git a/spec/src/main/java/io/a2a/spec/TaskState.java b/spec/src/main/java/io/a2a/spec/TaskState.java
index 30d3c1a23..f4171d98c 100644
--- a/spec/src/main/java/io/a2a/spec/TaskState.java
+++ b/spec/src/main/java/io/a2a/spec/TaskState.java
@@ -4,40 +4,92 @@
import com.fasterxml.jackson.annotation.JsonValue;
/**
- * Represents the state of a task.
+ * Enumeration representing the possible states of a task in the A2A protocol.
+ * Tasks progress through various states from submission to completion or termination.
*/
public enum TaskState {
+ /** Task has been submitted and is waiting to be processed */
SUBMITTED("submitted"),
+
+ /** Task is currently being processed by the agent */
WORKING("working"),
+
+ /** Task requires additional input from the user to continue */
INPUT_REQUIRED("input-required"),
+
+ /** Task requires authentication or authorization to proceed */
AUTH_REQUIRED("auth-required"),
+
+ /** Task has been successfully completed */
COMPLETED("completed", true),
+
+ /** Task has been canceled by the user or system */
CANCELED("canceled", true),
+
+ /** Task has failed due to an error or exception */
FAILED("failed", true),
+
+ /** Task has been rejected by the agent (e.g., invalid request) */
REJECTED("rejected", true),
+
+ /** Task state is unknown or could not be determined */
UNKNOWN("unknown", true);
+ /** The string representation of this state for JSON serialization */
private final String state;
+
+ /** Whether this state represents a final/terminal state */
private final boolean isFinal;
+ /**
+ * Constructs a TaskState with the specified string representation.
+ * The state is considered non-final by default.
+ *
+ * @param state the string representation of this state
+ */
TaskState(String state) {
this(state, false);
}
+ /**
+ * Constructs a TaskState with the specified string representation and finality.
+ *
+ * @param state the string representation of this state
+ * @param isFinal whether this state is final/terminal
+ */
TaskState(String state, boolean isFinal) {
this.state = state;
this.isFinal = isFinal;
}
+ /**
+ * Returns the string representation of this state for JSON serialization.
+ *
+ * @return the state string
+ */
@JsonValue
public String asString() {
return state;
}
+ /**
+ * Checks whether this state represents a final/terminal state.
+ * Final states indicate that the task has reached its end and will not transition further.
+ *
+ * @return {@code true} if this is a final state, {@code false} otherwise
+ */
public boolean isFinal(){
return isFinal;
}
+ /**
+ * Creates a TaskState from its string representation.
+ * This method is used for JSON deserialization.
+ *
+ * @param state the string representation of the task state
+ * @return the corresponding TaskState enum value
+ * @throws IllegalArgumentException if the state string is not recognized
+ */
@JsonCreator
public static TaskState fromString(String state) {
switch (state) {
diff --git a/spec/src/main/java/io/a2a/spec/TaskStatus.java b/spec/src/main/java/io/a2a/spec/TaskStatus.java
index 2befdfcbf..d5a4749a2 100644
--- a/spec/src/main/java/io/a2a/spec/TaskStatus.java
+++ b/spec/src/main/java/io/a2a/spec/TaskStatus.java
@@ -9,18 +9,39 @@
import io.a2a.util.Assert;
/**
- * Represents the status of a task.
+ * Represents the current status of a task in the A2A protocol.
+ * Contains the task's current state, an optional status message, and a timestamp
+ * indicating when this status was recorded.
+ *
+ * @param state the current state of the task (e.g., pending, in_progress, completed, failed)
+ * @param message an optional message providing additional context about the current status
+ * @param timestamp when this status was recorded (automatically set to current time if null)
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public record TaskStatus(TaskState state, Message message,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS") LocalDateTime timestamp) {
+ /**
+ * Compact constructor that validates and initializes the task status.
+ *
+ * This constructor ensures that the task state is not null and automatically
+ * sets the timestamp to the current time if it is not provided.
+ *
+ *
+ * @throws IllegalArgumentException if state is null
+ */
public TaskStatus {
Assert.checkNotNullParam("state", state);
timestamp = timestamp == null ? LocalDateTime.now() : timestamp;
}
+ /**
+ * Convenience constructor for creating a TaskStatus with only a state.
+ * The message will be null and timestamp will be set to the current time.
+ *
+ * @param state the current state of the task
+ */
public TaskStatus(TaskState state) {
this(state, null, null);
}
diff --git a/spec/src/main/java/io/a2a/spec/TaskStatusUpdateEvent.java b/spec/src/main/java/io/a2a/spec/TaskStatusUpdateEvent.java
index 7a44480da..d61e656f5 100644
--- a/spec/src/main/java/io/a2a/spec/TaskStatusUpdateEvent.java
+++ b/spec/src/main/java/io/a2a/spec/TaskStatusUpdateEvent.java
@@ -9,26 +9,79 @@
import io.a2a.util.Assert;
/**
- * A task status update event.
+ * Represents a task status update event in the A2A protocol.
+ *
+ * This event is emitted when a task's status changes during execution,
+ * providing real-time updates about task progress, completion, or failure.
+ * It implements both {@link EventKind} and {@link StreamingEventKind} to support
+ * different event processing patterns in the A2A framework.
+ *
+ * The event contains information about which task was updated, its new status,
+ * the context it belongs to, whether this is a final status change, and any
+ * additional metadata associated with the status update.
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public final class TaskStatusUpdateEvent implements EventKind, StreamingEventKind {
public static final String STATUS_UPDATE = "status-update";
+ /**
+ * The unique identifier of the task whose status was updated.
+ */
private final String taskId;
+
+ /**
+ * The new status of the task after the update.
+ */
private final TaskStatus status;
+
+ /**
+ * The identifier of the context/conversation this task belongs to.
+ */
private final String contextId;
+
+ /**
+ * Indicates whether this status update represents a final state.
+ * If true, no further status updates are expected for this task.
+ */
private final boolean isFinal;
+
+ /**
+ * Additional metadata associated with this status update.
+ * Can contain implementation-specific information about the status change.
+ */
private final Map metadata;
+
+ /**
+ * The kind/type of this event, always "status-update" for TaskStatusUpdateEvent instances.
+ */
private final String kind;
+ /**
+ * Constructs a new TaskStatusUpdateEvent with the specified properties.
+ *
+ * @param taskId the unique identifier of the task whose status was updated
+ * @param status the new status of the task after the update
+ * @param contextId the identifier of the context/conversation this task belongs to
+ * @param isFinal whether this status update represents a final state
+ * @param metadata additional metadata associated with this status update
+ */
public TaskStatusUpdateEvent(String taskId, TaskStatus status, String contextId, boolean isFinal,
Map metadata) {
this(taskId, status, contextId, isFinal, metadata, STATUS_UPDATE);
}
+ /**
+ * JSON constructor for creating TaskStatusUpdateEvent instances from JSON data.
+ *
+ * @param taskId the unique identifier of the task whose status was updated
+ * @param status the new status of the task after the update
+ * @param contextId the identifier of the context/conversation this task belongs to
+ * @param isFinal whether this status update represents a final state
+ * @param metadata additional metadata associated with this status update
+ * @param kind the kind/type of this event
+ */
@JsonCreator
public TaskStatusUpdateEvent(@JsonProperty("taskId") String taskId, @JsonProperty("status") TaskStatus status,
@JsonProperty("contextId") String contextId, @JsonProperty("final") boolean isFinal,
@@ -48,32 +101,65 @@ public TaskStatusUpdateEvent(@JsonProperty("taskId") String taskId, @JsonPropert
this.kind = kind;
}
+ /**
+ * Gets the unique identifier of the task whose status was updated.
+ *
+ * @return the task ID
+ */
public String getTaskId() {
return taskId;
}
+ /**
+ * Gets the new status of the task after the update.
+ *
+ * @return the task status
+ */
public TaskStatus getStatus() {
return status;
}
+ /**
+ * Gets the identifier of the context/conversation this task belongs to.
+ *
+ * @return the context ID
+ */
public String getContextId() {
return contextId;
}
+ /**
+ * Indicates whether this status update represents a final state.
+ *
+ * @return true if this is a final status update, false otherwise
+ */
@JsonProperty("final")
public boolean isFinal() {
return isFinal;
}
+ /**
+ * Gets the additional metadata associated with this status update.
+ *
+ * @return the metadata map
+ */
public Map getMetadata() {
return metadata;
}
+ /**
+ * Gets the kind/type of this event.
+ *
+ * @return the event kind, always "status-update" for TaskStatusUpdateEvent instances
+ */
@Override
public String getKind() {
return kind;
}
+ /**
+ * Builder class for constructing {@link TaskStatusUpdateEvent} instances.
+ */
public static class Builder {
private String taskId;
private TaskStatus status;
@@ -81,31 +167,66 @@ public static class Builder {
private boolean isFinal;
private Map metadata;
+ /**
+ * Sets the unique identifier of the task whose status was updated.
+ *
+ * @param id the task ID
+ * @return this builder instance
+ */
public Builder taskId(String id) {
this.taskId = id;
return this;
}
+ /**
+ * Sets the new status of the task after the update.
+ *
+ * @param status the task status
+ * @return this builder instance
+ */
public Builder status(TaskStatus status) {
this.status = status;
return this;
}
+ /**
+ * Sets the identifier of the context/conversation this task belongs to.
+ *
+ * @param contextId the context ID
+ * @return this builder instance
+ */
public Builder contextId(String contextId) {
this.contextId = contextId;
return this;
}
+ /**
+ * Sets whether this status update represents a final state.
+ *
+ * @param isFinal true if this is a final status update, false otherwise
+ * @return this builder instance
+ */
public Builder isFinal(boolean isFinal) {
this.isFinal = isFinal;
return this;
}
+ /**
+ * Sets the additional metadata associated with this status update.
+ *
+ * @param metadata the metadata map
+ * @return this builder instance
+ */
public Builder metadata(Map metadata) {
this.metadata = metadata;
return this;
}
+ /**
+ * Builds and returns a new {@link TaskStatusUpdateEvent} instance with the configured properties.
+ *
+ * @return a new TaskStatusUpdateEvent instance
+ */
public TaskStatusUpdateEvent build() {
return new TaskStatusUpdateEvent(taskId, status, contextId, isFinal, metadata);
}
diff --git a/spec/src/main/java/io/a2a/spec/TextPart.java b/spec/src/main/java/io/a2a/spec/TextPart.java
index 1b62cf747..ec9494440 100644
--- a/spec/src/main/java/io/a2a/spec/TextPart.java
+++ b/spec/src/main/java/io/a2a/spec/TextPart.java
@@ -9,19 +9,45 @@
import io.a2a.util.Assert;
/**
+ * A text content part that contains string content.
+ * This is one of the most common part types used for textual communication
+ * in the A2A protocol.
+ *
* A fundamental text unit of an Artifact or Message.
*/
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public class TextPart extends Part {
+ /**
+ * The text content of this part.
+ */
private final String text;
+
+ /**
+ * Additional metadata associated with this text part.
+ */
private final Map metadata;
+
+ /**
+ * The kind of this part, always TEXT for TextPart instances.
+ */
private final Kind kind;
+ /**
+ * Constructs a new TextPart with the specified text content and no metadata.
+ *
+ * @param text the text content
+ */
public TextPart(String text) {
this(text, null);
}
+ /**
+ * Constructs a new TextPart with the specified text content and metadata.
+ *
+ * @param text the text content
+ * @param metadata additional metadata for this text part
+ */
@JsonCreator
public TextPart(@JsonProperty("text") String text, @JsonProperty("metadata") Map metadata) {
Assert.checkNotNullParam("text", text);
@@ -30,15 +56,30 @@ public TextPart(@JsonProperty("text") String text, @JsonProperty("metadata") Map
this.kind = Kind.TEXT;
}
+ /**
+ * Returns the kind of this part.
+ *
+ * @return the part kind, always Kind.TEXT
+ */
@Override
public Kind getKind() {
return kind;
}
+ /**
+ * Returns the text content of this part.
+ *
+ * @return the text content
+ */
public String getText() {
return text;
}
+ /**
+ * Returns the metadata associated with this text part.
+ *
+ * @return the metadata map
+ */
@Override
public Map getMetadata() {
return metadata;
diff --git a/spec/src/main/java/io/a2a/spec/UnsupportedOperationError.java b/spec/src/main/java/io/a2a/spec/UnsupportedOperationError.java
index d5ee0fb44..9685fee8e 100644
--- a/spec/src/main/java/io/a2a/spec/UnsupportedOperationError.java
+++ b/spec/src/main/java/io/a2a/spec/UnsupportedOperationError.java
@@ -7,12 +7,40 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+/**
+ * Represents a JSON-RPC 2.0 error indicating that a requested operation is not supported.
+ * This error is returned when a client attempts to invoke a method or perform an action
+ * that is not implemented or available in the current agent configuration.
+ *
+ * Common scenarios where this error occurs:
+ *
+ * - Calling a method that is not implemented by the agent
+ * - Requesting features that are disabled in the current configuration
+ * - Using deprecated methods that are no longer supported
+ * - Attempting operations that require capabilities not available in this agent version
+ *
+ *
+ * The error follows JSON-RPC 2.0 error object specification with a default
+ * error code of -32004 and a descriptive message. Additional context about
+ * the unsupported operation can be provided through the data field.
+ *
+ * @see JSONRPCError
+ */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonIgnoreProperties(ignoreUnknown = true)
public class UnsupportedOperationError extends JSONRPCError {
+ /** Default error code for unsupported operation errors */
public final static Integer DEFAULT_CODE = -32004;
+ /**
+ * Creates an UnsupportedOperationError with custom values.
+ * Any null parameters will be replaced with default values.
+ *
+ * @param code the error code (defaults to -32004 if null)
+ * @param message the error message (defaults to "This operation is not supported" if null)
+ * @param data additional error data, such as the unsupported method name (can be null)
+ */
@JsonCreator
public UnsupportedOperationError(
@JsonProperty("code") Integer code,
@@ -24,6 +52,10 @@ public UnsupportedOperationError(
data);
}
+ /**
+ * Creates an UnsupportedOperationError with default values.
+ * Uses the default error code and message.
+ */
public UnsupportedOperationError() {
this(null, null, null);
}