From 5d5132b74d45b0372df7d0b302b2ddb0cfebb3bd Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Wed, 6 Aug 2025 15:50:56 +0000 Subject: [PATCH 01/23] a script for generating a jsonrpc types from a2a json-schema --- go.mod | 2 +- tools/jsonrpc_gen.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100755 tools/jsonrpc_gen.sh diff --git a/go.mod b/go.mod index f7b68a81..849fe269 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/a2aproject/a2a +module github.com/a2aproject/a2a-go go 1.24.4 diff --git a/tools/jsonrpc_gen.sh b/tools/jsonrpc_gen.sh new file mode 100755 index 00000000..0977521f --- /dev/null +++ b/tools/jsonrpc_gen.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -euo pipefail + +# Configuration +SCHEMA_URL="https://raw.githubusercontent.com/a2aproject/A2A/main/specification/json/a2a.json" +SCHEMA_FILE="a2a.json" +OUTPUT_DIR="./internal/jsonrpc" +OUTPUT_FILE="spec.go" +PACKAGE_NAME="jsonrpc" + +mkdir -p "$OUTPUT_DIR" + +echo "Created output directory: $OUTPUT_DIR" + +echo "Downloading A2A JSON schema..." + +curl -s -o "$SCHEMA_FILE" "$SCHEMA_URL" + +echo "Generating Go types..." + +go-jsonschema \ + --package "$PACKAGE_NAME" \ + --output "$OUTPUT_DIR/$OUTPUT_FILE" \ + "$SCHEMA_FILE" + +echo "Formatting generated Go code..." + +gofmt -w "$OUTPUT_DIR/$OUTPUT_FILE" + +# Clean up downloaded schema file +rm -f "$SCHEMA_FILE" +echo "Cleaned up temporary files" + +echo "Done: $OUTPUT_DIR/$OUTPUT_FILE" \ No newline at end of file From 712dbe63e73e6cf0801ccc82e42568ce7bd8bfb1 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Wed, 6 Aug 2025 15:52:44 +0000 Subject: [PATCH 02/23] generate plain types from a2a json-schema --- a2a/types.go | 1502 +++++++++++++++++++++++++++++++++++++++++ tools/jsonrpc2spec.go | 171 +++++ 2 files changed, 1673 insertions(+) create mode 100644 a2a/types.go create mode 100644 tools/jsonrpc2spec.go diff --git a/a2a/types.go b/a2a/types.go new file mode 100644 index 00000000..ddc66754 --- /dev/null +++ b/a2a/types.go @@ -0,0 +1,1502 @@ +// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. + +package jsonrpc + + +// A discriminated union of all standard JSON-RPC and A2A-specific error types. +type A2AError any + +// A discriminated union representing all possible JSON-RPC 2.0 requests supported +// by the A2A specification. +type A2ARequest any + +// Defines a security scheme using an API key. +type APIKeySecurityScheme struct { + // An optional description for the security scheme. + Description *string + + // The location of the API key. + In APIKeySecuritySchemeIn + + // The name of the header, query, or cookie parameter to be used. + Name string + + // The type of the security scheme. Must be 'apiKey'. + Type string +} + +type APIKeySecuritySchemeIn string + +const APIKeySecuritySchemeInCookie APIKeySecuritySchemeIn = "cookie" +const APIKeySecuritySchemeInHeader APIKeySecuritySchemeIn = "header" +const APIKeySecuritySchemeInQuery APIKeySecuritySchemeIn = "query" + + + + + + +// Defines optional capabilities supported by an agent. +type AgentCapabilities struct { + // A list of protocol extensions supported by the agent. + Extensions []AgentExtension + + // Indicates if the agent supports sending push notifications for asynchronous + // task updates. + PushNotifications *bool + + // Indicates if the agent provides a history of state transitions for a task. + StateTransitionHistory *bool + + // Indicates if the agent supports Server-Sent Events (SSE) for streaming + // responses. + Streaming *bool +} + +// The AgentCard is a self-describing manifest for an agent. It provides essential +// metadata including the agent's identity, capabilities, skills, supported +// communication methods, and security requirements. +type AgentCard struct { + // A list of additional supported interfaces (transport and URL combinations). + // This allows agents to expose multiple transports, potentially at different + // URLs. + // + // Best practices: + // - SHOULD include all supported transports for completeness + // - SHOULD include an entry matching the main 'url' and 'preferredTransport' + // - MAY reuse URLs if multiple transports are available at the same endpoint + // - MUST accurately declare the transport available at each URL + // + // Clients can select any interface from this list based on their transport + // capabilities + // and preferences. This enables transport negotiation and fallback scenarios. + AdditionalInterfaces []AgentInterface + + // A declaration of optional capabilities supported by the agent. + Capabilities AgentCapabilities + + // Default set of supported input MIME types for all skills, which can be + // overridden on a per-skill basis. + DefaultInputModes []string + + // Default set of supported output MIME types for all skills, which can be + // overridden on a per-skill basis. + DefaultOutputModes []string + + // A human-readable description of the agent, assisting users and other agents + // in understanding its purpose. + Description string + + // An optional URL to the agent's documentation. + DocumentationURL *string + + // An optional URL to an icon for the agent. + IconURL *string + + // A human-readable name for the agent. + Name string + + // The transport protocol for the preferred endpoint (the main 'url' field). + // If not specified, defaults to 'JSONRPC'. + // + // IMPORTANT: The transport specified here MUST be available at the main 'url'. + // This creates a binding between the main URL and its supported transport + // protocol. + // Clients should prefer this transport and URL combination when both are + // supported. + PreferredTransport string + + // The version of the A2A protocol this agent supports. + ProtocolVersion string + + // Information about the agent's service provider. + Provider *AgentProvider + + // A list of security requirement objects that apply to all agent interactions. + // Each object + // lists security schemes that can be used. Follows the OpenAPI 3.0 Security + // Requirement Object. + // This list can be seen as an OR of ANDs. Each object in the list describes one + // possible + // set of security requirements that must be present on a request. This allows + // specifying, + // for example, "callers must either use OAuth OR an API Key AND mTLS." + Security []map[string][]string + + // A declaration of the security schemes available to authorize requests. The key + // is the + // scheme name. Follows the OpenAPI 3.0 Security Scheme Object. + SecuritySchemes map[string]any + + // JSON Web Signatures computed for this AgentCard. + Signatures []AgentCardSignature + + // The set of skills, or distinct capabilities, that the agent can perform. + Skills []AgentSkill + + // If true, the agent can provide an extended agent card with additional details + // to authenticated users. Defaults to false. + SupportsAuthenticatedExtendedCard *bool + + // The preferred endpoint URL for interacting with the agent. + // This URL MUST support the transport specified by 'preferredTransport'. + URL string + + // The agent's own version number. The format is defined by the provider. + Version string +} + +// AgentCardSignature represents a JWS signature of an AgentCard. +// This follows the JSON format of an RFC 7515 JSON Web Signature (JWS). +type AgentCardSignature struct { + // The unprotected JWS header values. + Header map[string]any + + // The protected JWS header for the signature. This is a Base64url-encoded + // JSON object, as per RFC 7515. + Protected string + + // The computed signature, Base64url-encoded. + Signature string +} + + + + + +// A declaration of a protocol extension supported by an Agent. +type AgentExtension struct { + // A human-readable description of how this agent uses the extension. + Description *string + + // Optional, extension-specific configuration parameters. + Params map[string]any + + // If true, the client must understand and comply with the extension's + // requirements + // to interact with the agent. + Required *bool + + // The unique URI identifying the extension. + Uri string +} + + + +// Declares a combination of a target URL and a transport protocol for interacting +// with the agent. +// This allows agents to expose the same functionality over multiple transport +// mechanisms. +type AgentInterface struct { + // The transport protocol supported at this URL. + Transport string + + // The URL where this interface is available. Must be a valid absolute HTTPS URL + // in production. + URL string +} + + + +// Represents the service provider of an agent. +type AgentProvider struct { + // The name of the agent provider's organization. + Organization string + + // A URL for the agent provider's website or relevant documentation. + URL string +} + + + +// Represents a distinct capability or function that an agent can perform. +type AgentSkill struct { + // A detailed description of the skill, intended to help clients or users + // understand its purpose and functionality. + Description string + + // Example prompts or scenarios that this skill can handle. Provides a hint to + // the client on how to use the skill. + Examples []string + + // A unique identifier for the agent's skill. + Id string + + // The set of supported input MIME types for this skill, overriding the agent's + // defaults. + InputModes []string + + // A human-readable name for the skill. + Name string + + // The set of supported output MIME types for this skill, overriding the agent's + // defaults. + OutputModes []string + + // Security schemes necessary for the agent to leverage this skill. + // As in the overall AgentCard.security, this list represents a logical OR of + // security + // requirement objects. Each object is a set of security schemes that must be used + // together + // (a logical AND). + Security []map[string][]string + + // A set of keywords describing the skill's capabilities. + Tags []string +} + + + +// Represents a file, data structure, or other resource generated by an agent +// during a task. +type Artifact struct { + // A unique identifier for the artifact within the scope of the task. + ArtifactId string + + // An optional, human-readable description of the artifact. + Description *string + + // The URIs of extensions that are relevant to this artifact. + Extensions []string + + // Optional metadata for extensions. The key is an extension-specific identifier. + Metadata map[string]any + + // An optional, human-readable name for the artifact. + Name *string + + // An array of content parts that make up the artifact. + Parts []ArtifactPartsElem +} + +type ArtifactPartsElem any + + + +// An A2A-specific error indicating that the agent does not have an Authenticated +// Extended Card configured +type AuthenticatedExtendedCardNotConfiguredError struct { + // The error code for when an authenticated extended card is not configured. + Code int + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data any + + // The error message. + Message string +} + + + +// Defines configuration details for the OAuth 2.0 Authorization Code flow. +type AuthorizationCodeOAuthFlow struct { + // The authorization URL to be used for this flow. + // This MUST be a URL and use TLS. + AuthorizationURL string + + // The URL to be used for obtaining refresh tokens. + // This MUST be a URL and use TLS. + RefreshURL *string + + // The available scopes for the OAuth2 security scheme. A map between the scope + // name and a short description for it. + Scopes map[string]string + + // The token URL to be used for this flow. + // This MUST be a URL and use TLS. + TokenURL string +} + + + +// Represents a request for the `tasks/cancel` method. +type CancelTaskRequest struct { + + + + // The parameters identifying the task to cancel. + Params TaskIdParams +} + + + +// Represents a response for the `tasks/cancel` method. +type CancelTaskResponse any + +// Represents a successful response for the `tasks/cancel` method. +type CancelTaskSuccessResponse struct { + + + // The result, containing the final state of the canceled Task object. + Result Task +} + + + +// Defines configuration details for the OAuth 2.0 Client Credentials flow. +type ClientCredentialsOAuthFlow struct { + // The URL to be used for obtaining refresh tokens. This MUST be a URL. + RefreshURL *string + + // The available scopes for the OAuth2 security scheme. A map between the scope + // name and a short description for it. + Scopes map[string]string + + // The token URL to be used for this flow. This MUST be a URL. + TokenURL string +} + + + +// An A2A-specific error indicating an incompatibility between the requested +// content types and the agent's capabilities. +type ContentTypeNotSupportedError struct { + // The error code for an unsupported content type. + Code int + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data any + + // The error message. + Message string +} + + + +// Represents a structured data segment (e.g., JSON) within a message or artifact. +type DataPart struct { + // The structured data content. + Data map[string]any + + // The type of this part, used as a discriminator. Always 'data'. + Kind string + + // Optional metadata associated with this part. + Metadata map[string]any +} + + + +// Defines parameters for deleting a specific push notification configuration for a +// task. +type DeleteTaskPushNotificationConfigParams struct { + // The unique identifier of the task. + Id string + + // Optional metadata associated with the request. + Metadata map[string]any + + // The ID of the push notification configuration to delete. + PushNotificationConfigId string +} + + + +// Represents a request for the `tasks/pushNotificationConfig/delete` +// method. +type DeleteTaskPushNotificationConfigRequest struct { + + + + // The parameters identifying the push notification configuration to delete. + Params DeleteTaskPushNotificationConfigParams +} + + + +// Represents a response for the `tasks/pushNotificationConfig/delete` +// method. +type DeleteTaskPushNotificationConfigResponse any + +// Represents a successful response for the +// `tasks/pushNotificationConfig/delete` method. +type DeleteTaskPushNotificationConfigSuccessResponse struct { + + + // The result is null on successful deletion. + Result any +} + + + +// Defines base properties for a file. +type FileBase struct { + // The MIME type of the file (e.g., "application/pdf"). + MimeType *string + + // An optional name for the file (e.g., "document.pdf"). + Name *string +} + +// Represents a file segment within a message or artifact. The file content can be +// provided either directly as bytes or as a URI. +type FilePart struct { + // The file content, represented as either a URI or as base64-encoded bytes. + File FilePartFile + + // The type of this part, used as a discriminator. Always 'file'. + Kind string + + // Optional metadata associated with this part. + Metadata map[string]any +} + +// Represents a file with its content provided directly as a base64-encoded string. +type FilePartFile struct { + // The base64-encoded content of the file. + Bytes string + + // The MIME type of the file (e.g., "application/pdf"). + MimeType *string + + // An optional name for the file (e.g., "document.pdf"). + Name *string + + // A URL pointing to the file's content. + Uri string +} + + + + + +// Represents a file with its content provided directly as a base64-encoded string. +type FileWithBytes struct { + // The base64-encoded content of the file. + Bytes string + + // The MIME type of the file (e.g., "application/pdf"). + MimeType *string + + // An optional name for the file (e.g., "document.pdf"). + Name *string +} + + + +// Represents a file with its content located at a specific URI. +type FileWithUri struct { + // The MIME type of the file (e.g., "application/pdf"). + MimeType *string + + // An optional name for the file (e.g., "document.pdf"). + Name *string + + // A URL pointing to the file's content. + Uri string +} + + + +// Represents a request for the `agent/getAuthenticatedExtendedCard` +// method. +type GetAuthenticatedExtendedCardRequest struct { + + +} + + + +// Represents a response for the `agent/getAuthenticatedExtendedCard` +// method. +type GetAuthenticatedExtendedCardResponse any + +// Represents a successful response for the +// `agent/getAuthenticatedExtendedCard` method. +type GetAuthenticatedExtendedCardSuccessResponse struct { + + + // The result is an Agent Card object. + Result AgentCard +} + + + +// Defines parameters for fetching a specific push notification configuration for a +// task. +type GetTaskPushNotificationConfigParams struct { + // The unique identifier of the task. + Id string + + // Optional metadata associated with the request. + Metadata map[string]any + + // The ID of the push notification configuration to retrieve. + PushNotificationConfigId *string +} + + + +// Represents a request for the `tasks/pushNotificationConfig/get` method. +type GetTaskPushNotificationConfigRequest struct { + + + + // The parameters for getting a push notification configuration. + Params GetTaskPushNotificationConfigRequestParams +} + +// Defines parameters containing a task ID, used for simple task operations. +type GetTaskPushNotificationConfigRequestParams struct { + // The unique identifier of the task. + Id string + + // Optional metadata associated with the request. + Metadata map[string]any + + // The ID of the push notification configuration to retrieve. + PushNotificationConfigId *string +} + + + + + +// Represents a response for the `tasks/pushNotificationConfig/get` +// method. +type GetTaskPushNotificationConfigResponse any + +// Represents a successful response for the +// `tasks/pushNotificationConfig/get` method. +type GetTaskPushNotificationConfigSuccessResponse struct { + + + // The result, containing the requested push notification configuration. + Result TaskPushNotificationConfig +} + + + +// Represents a request for the `tasks/get` method. +type GetTaskRequest struct { + + + + // The parameters for querying a task. + Params TaskQueryParams +} + + + +// Represents a response for the `tasks/get` method. +type GetTaskResponse any + +// Represents a successful response for the `tasks/get` method. +type GetTaskSuccessResponse struct { + + + // The result, containing the requested Task object. + Result Task +} + + + +// Defines a security scheme using HTTP authentication. +type HTTPAuthSecurityScheme struct { + // A hint to the client to identify how the bearer token is formatted (e.g., + // "JWT"). + // This is primarily for documentation purposes. + BearerFormat *string + + // An optional description for the security scheme. + Description *string + + // The name of the HTTP Authentication scheme to be used in the Authorization + // header, + // as defined in RFC7235 (e.g., "Bearer"). + // This value should be registered in the IANA Authentication Scheme registry. + Scheme string + + // The type of the security scheme. Must be 'http'. + Type string +} + + + +// Defines configuration details for the OAuth 2.0 Implicit flow. +type ImplicitOAuthFlow struct { + // The authorization URL to be used for this flow. This MUST be a URL. + AuthorizationURL string + + // The URL to be used for obtaining refresh tokens. This MUST be a URL. + RefreshURL *string + + // The available scopes for the OAuth2 security scheme. A map between the scope + // name and a short description for it. + Scopes map[string]string +} + + + +// An error indicating an internal error on the server. +type InternalError struct { + // The error code for an internal server error. + Code int + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data any + + // The error message. + Message string +} + + + +// An A2A-specific error indicating that the agent returned a response that +// does not conform to the specification for the current method. +type InvalidAgentResponseError struct { + // The error code for an invalid agent response. + Code int + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data any + + // The error message. + Message string +} + + + +// An error indicating that the method parameters are invalid. +type InvalidParamsError struct { + // The error code for an invalid parameters error. + Code int + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data any + + // The error message. + Message string +} + + + +// An error indicating that the JSON sent is not a valid Request object. +type InvalidRequestError struct { + // The error code for an invalid request. + Code int + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data any + + // The error message. + Message string +} + + + +// An error indicating that the server received invalid JSON. +type JSONParseError struct { + // The error code for a JSON parse error. + Code int + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data any + + // The error message. + Message string +} + + + +// Represents a JSON-RPC 2.0 Error object, included in an error response. +type JSONRPCError struct { + // A number that indicates the error type that occurred. + Code int + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data any + + // A string providing a short description of the error. + Message string +} + +// Represents a JSON-RPC 2.0 Error Response object. +type JSONRPCErrorResponse struct { + // An object describing the error that occurred. + Error JSONRPCErrorResponseError + + +} + +// Represents a JSON-RPC 2.0 Error object, included in an error response. +type JSONRPCErrorResponseError struct { + // A number that indicates the error type that occurred. + Code int + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data any + + // A string providing a short description of the error. + Message string +} + + + + + + + +// Defines the base structure for any JSON-RPC 2.0 request, response, or +// notification. +type JSONRPCMessage struct { + // A unique identifier established by the client. It must be a String, a Number, + // or null. + // The server must reply with the same value in the response. This property is + // omitted for notifications. + +} + + + +// Represents a JSON-RPC 2.0 Request object. +type JSONRPCRequest struct { + // A unique identifier established by the client. It must be a String, a Number, + // or null. + // The server must reply with the same value in the response. This property is + // omitted for notifications. + + + // A string containing the name of the method to be invoked. + + // A structured value holding the parameter values to be used during the method + // invocation. + Params map[string]any +} + + + +// A discriminated union representing all possible JSON-RPC 2.0 responses +// for the A2A specification methods. +type JSONRPCResponse any + +// Represents a successful JSON-RPC 2.0 Response object. +type JSONRPCSuccessResponse struct { + + + // The value of this member is determined by the method invoked on the Server. + Result any +} + + + +// Defines parameters for listing all push notification configurations associated +// with a task. +type ListTaskPushNotificationConfigParams struct { + // The unique identifier of the task. + Id string + + // Optional metadata associated with the request. + Metadata map[string]any +} + + + +// Represents a request for the `tasks/pushNotificationConfig/list` +// method. +type ListTaskPushNotificationConfigRequest struct { + + + + // The parameters identifying the task whose configurations are to be listed. + Params ListTaskPushNotificationConfigParams +} + + + +// Represents a response for the `tasks/pushNotificationConfig/list` +// method. +type ListTaskPushNotificationConfigResponse any + +// Represents a successful response for the +// `tasks/pushNotificationConfig/list` method. +type ListTaskPushNotificationConfigSuccessResponse struct { + + + // The result, containing an array of all push notification configurations for the + // task. + Result []TaskPushNotificationConfig +} + + + +// Represents a single message in the conversation between a user and an agent. +type Message struct { + // The context identifier for this message, used to group related interactions. + ContextId *string + + // The URIs of extensions that are relevant to this message. + Extensions []string + + // The type of this object, used as a discriminator. Always 'message' for a + // Message. + Kind string + + // A unique identifier for the message, typically a UUID, generated by the sender. + MessageId string + + // Optional metadata for extensions. The key is an extension-specific identifier. + Metadata map[string]any + + // An array of content parts that form the message body. A message can be + // composed of multiple parts of different types (e.g., text and files). + Parts []MessagePartsElem + + // A list of other task IDs that this message references for additional context. + ReferenceTaskIds []string + + // Identifies the sender of the message. + // service. + Role MessageRole + + // The identifier of the task this message is part of. Can be omitted for the + // first message of a new task. + TaskId *string +} + +type MessagePartsElem any + +type MessageRole string + +const MessageRoleAgent MessageRole = "agent" +const MessageRoleUser MessageRole = "user" + + + + +// Defines configuration options for a `message/send` or `message/stream` request. +type MessageSendConfiguration struct { + // A list of output MIME types the client is prepared to accept in the response. + AcceptedOutputModes []string + + // If true, the client will wait for the task to complete. The server may reject + // this if the task is long-running. + Blocking *bool + + // The number of most recent messages from the task's history to retrieve in the + // response. + HistoryLength *int + + // Configuration for the agent to send push notifications for updates after the + // initial response. + PushNotificationConfig *PushNotificationConfig +} + +// Defines the parameters for a request to send a message to an agent. This can be +// used +// to create a new task, continue an existing one, or restart a task. +type MessageSendParams struct { + // Optional configuration for the send request. + Configuration *MessageSendConfiguration + + // The message object being sent to the agent. + Message Message + + // Optional metadata for extensions. + Metadata map[string]any +} + + + + + +// An error indicating that the requested method does not exist or is not +// available. +type MethodNotFoundError struct { + // The error code for a method not found error. + Code int + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data any + + // The error message. + Message string +} + + + +// Defines a security scheme using mTLS authentication. +type MutualTLSSecurityScheme struct { + // An optional description for the security scheme. + Description *string + + // The type of the security scheme. Must be 'mutualTLS'. + Type string +} + + + +// Defines a security scheme using OAuth 2.0. +type OAuth2SecurityScheme struct { + // An optional description for the security scheme. + Description *string + + // An object containing configuration information for the supported OAuth 2.0 + // flows. + Flows OAuthFlows + + // URL to the oauth2 authorization server metadata + // [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414). TLS is required. + Oauth2MetadataURL *string + + // The type of the security scheme. Must be 'oauth2'. + Type string +} + + + +// Defines the configuration for the supported OAuth 2.0 flows. +type OAuthFlows struct { + // Configuration for the OAuth Authorization Code flow. Previously called + // accessCode in OpenAPI 2.0. + AuthorizationCode *AuthorizationCodeOAuthFlow + + // Configuration for the OAuth Client Credentials flow. Previously called + // application in OpenAPI 2.0. + ClientCredentials *ClientCredentialsOAuthFlow + + // Configuration for the OAuth Implicit flow. + Implicit *ImplicitOAuthFlow + + // Configuration for the OAuth Resource Owner Password flow. + Password *PasswordOAuthFlow +} + +// Defines a security scheme using OpenID Connect. +type OpenIdConnectSecurityScheme struct { + // An optional description for the security scheme. + Description *string + + // The OpenID Connect Discovery URL for the OIDC provider's metadata. + OpenIdConnectURL string + + // The type of the security scheme. Must be 'openIdConnect'. + Type string +} + + + +// A discriminated union representing a part of a message or artifact, which can +// be text, a file, or structured data. +type Part any + +// Defines base properties common to all message or artifact parts. +type PartBase struct { + // Optional metadata associated with this part. + Metadata map[string]any +} + +// Defines configuration details for the OAuth 2.0 Resource Owner Password flow. +type PasswordOAuthFlow struct { + // The URL to be used for obtaining refresh tokens. This MUST be a URL. + RefreshURL *string + + // The available scopes for the OAuth2 security scheme. A map between the scope + // name and a short description for it. + Scopes map[string]string + + // The token URL to be used for this flow. This MUST be a URL. + TokenURL string +} + + + +// Defines authentication details for a push notification endpoint. +type PushNotificationAuthenticationInfo struct { + // Optional credentials required by the push notification endpoint. + Credentials *string + + // A list of supported authentication schemes (e.g., 'Basic', 'Bearer'). + Schemes []string +} + + + +// Defines the configuration for setting up push notifications for task updates. +type PushNotificationConfig struct { + // Optional authentication details for the agent to use when calling the + // notification URL. + Authentication *PushNotificationAuthenticationInfo + + // A unique ID for the push notification configuration, set by the client + // to support multiple notification callbacks. + Id *string + + // A unique token for this task or session to validate incoming push + // notifications. + Token *string + + // The callback URL where the agent should send push notifications. + URL string +} + + + +// An A2A-specific error indicating that the agent does not support push +// notifications. +type PushNotificationNotSupportedError struct { + // The error code for when push notifications are not supported. + Code int + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data any + + // The error message. + Message string +} + + + +// Defines a security scheme that can be used to secure an agent's endpoints. +// This is a discriminated union type based on the OpenAPI 3.0 Security Scheme +// Object. +type SecurityScheme any + +// Defines base properties shared by all security scheme objects. +type SecuritySchemeBase struct { + // An optional description for the security scheme. + Description *string +} + +// Represents a request for the `message/send` method. +type SendMessageRequest struct { + + + + // The parameters for sending a message. + Params MessageSendParams +} + + + +// Represents a response for the `message/send` method. +type SendMessageResponse any + +// Represents a successful response for the `message/send` method. +type SendMessageSuccessResponse struct { + + + // The result, which can be a direct reply Message or the initial Task object. + Result SendMessageSuccessResponseResult +} + +// Represents a single, stateful operation or conversation between a client and an +// agent. +type SendMessageSuccessResponseResult struct { + // A collection of artifacts generated by the agent during the execution of the + // task. + Artifacts []Artifact + + // A server-generated identifier for maintaining context across multiple related + // tasks or interactions. + ContextId string + + // The URIs of extensions that are relevant to this message. + Extensions []string + + // An array of messages exchanged during the task, representing the conversation + // history. + History []Message + + // A unique identifier for the task, generated by the server for a new task. + Id string + + // The type of this object, used as a discriminator. Always 'task' for a Task. + Kind string + + // A unique identifier for the message, typically a UUID, generated by the sender. + MessageId string + + // Optional metadata for extensions. The key is an extension-specific identifier. + Metadata map[string]any + + // An array of content parts that form the message body. A message can be + // composed of multiple parts of different types (e.g., text and files). + Parts []MessagePartsElem + + // A list of other task IDs that this message references for additional context. + ReferenceTaskIds []string + + // Identifies the sender of the message. + // service. + Role MessageRole + + // The current status of the task, including its state and a descriptive message. + Status TaskStatus + + // The identifier of the task this message is part of. Can be omitted for the + // first message of a new task. + TaskId *string +} + + + + + +// Represents a request for the `message/stream` method. +type SendStreamingMessageRequest struct { + + + + // The parameters for sending a message. + Params MessageSendParams +} + + + +// Represents a response for the `message/stream` method. +type SendStreamingMessageResponse any + +// Represents a successful response for the `message/stream` method. +// The server may send multiple response objects for a single request. +type SendStreamingMessageSuccessResponse struct { + + + // The result, which can be a Message, Task, or a streaming update event. + Result SendStreamingMessageSuccessResponseResult +} + +// Represents a single, stateful operation or conversation between a client and an +// agent. +type SendStreamingMessageSuccessResponseResult struct { + // If true, the content of this artifact should be appended to a previously sent + // artifact with the same ID. + Append *bool + + // The artifact that was generated or updated. + Artifact Artifact + + // A collection of artifacts generated by the agent during the execution of the + // task. + Artifacts []Artifact + + // A server-generated identifier for maintaining context across multiple related + // tasks or interactions. + ContextId string + + // The URIs of extensions that are relevant to this message. + Extensions []string + + // If true, this is the final event in the stream for this interaction. + Final bool + + // An array of messages exchanged during the task, representing the conversation + // history. + History []Message + + // A unique identifier for the task, generated by the server for a new task. + Id string + + // The type of this object, used as a discriminator. Always 'task' for a Task. + Kind string + + // If true, this is the final chunk of the artifact. + LastChunk *bool + + // A unique identifier for the message, typically a UUID, generated by the sender. + MessageId string + + // Optional metadata for extensions. The key is an extension-specific identifier. + Metadata map[string]any + + // An array of content parts that form the message body. A message can be + // composed of multiple parts of different types (e.g., text and files). + Parts []MessagePartsElem + + // A list of other task IDs that this message references for additional context. + ReferenceTaskIds []string + + // Identifies the sender of the message. + // service. + Role MessageRole + + // The current status of the task, including its state and a descriptive message. + Status TaskStatus + + // The identifier of the task this message is part of. Can be omitted for the + // first message of a new task. + TaskId string +} + + + + + +// Represents a request for the `tasks/pushNotificationConfig/set` method. +type SetTaskPushNotificationConfigRequest struct { + + + + // The parameters for setting the push notification configuration. + Params TaskPushNotificationConfig +} + + + +// Represents a response for the `tasks/pushNotificationConfig/set` +// method. +type SetTaskPushNotificationConfigResponse any + +// Represents a successful response for the +// `tasks/pushNotificationConfig/set` method. +type SetTaskPushNotificationConfigSuccessResponse struct { + + + // The result, containing the configured push notification settings. + Result TaskPushNotificationConfig +} + + + +// Represents a single, stateful operation or conversation between a client and an +// agent. +type Task struct { + // A collection of artifacts generated by the agent during the execution of the + // task. + Artifacts []Artifact + + // A server-generated identifier for maintaining context across multiple related + // tasks or interactions. + ContextId string + + // An array of messages exchanged during the task, representing the conversation + // history. + History []Message + + // A unique identifier for the task, generated by the server for a new task. + Id string + + // The type of this object, used as a discriminator. Always 'task' for a Task. + Kind string + + // Optional metadata for extensions. The key is an extension-specific identifier. + Metadata map[string]any + + // The current status of the task, including its state and a descriptive message. + Status TaskStatus +} + +// An event sent by the agent to notify the client that an artifact has been +// generated or updated. This is typically used in streaming models. +type TaskArtifactUpdateEvent struct { + // If true, the content of this artifact should be appended to a previously sent + // artifact with the same ID. + Append *bool + + // The artifact that was generated or updated. + Artifact Artifact + + // The context ID associated with the task. + ContextId string + + // The type of this event, used as a discriminator. Always 'artifact-update'. + Kind string + + // If true, this is the final chunk of the artifact. + LastChunk *bool + + // Optional metadata for extensions. + Metadata map[string]any + + // The ID of the task this artifact belongs to. + TaskId string +} + + + +// Defines parameters containing a task ID, used for simple task operations. +type TaskIdParams struct { + // The unique identifier of the task. + Id string + + // Optional metadata associated with the request. + Metadata map[string]any +} + + + +// An A2A-specific error indicating that the task is in a state where it cannot be +// canceled. +type TaskNotCancelableError struct { + // The error code for a task that cannot be canceled. + Code int + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data any + + // The error message. + Message string +} + + + +// An A2A-specific error indicating that the requested task ID was not found. +type TaskNotFoundError struct { + // The error code for a task not found error. + Code int + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data any + + // The error message. + Message string +} + + + +// A container associating a push notification configuration with a specific task. +type TaskPushNotificationConfig struct { + // The push notification configuration for this task. + PushNotificationConfig PushNotificationConfig + + // The ID of the task. + TaskId string +} + + + +// Defines parameters for querying a task, with an option to limit history length. +type TaskQueryParams struct { + // The number of most recent messages from the task's history to retrieve. + HistoryLength *int + + // The unique identifier of the task. + Id string + + // Optional metadata associated with the request. + Metadata map[string]any +} + + + +// Represents a request for the `tasks/resubscribe` method, used to resume +// a streaming connection. +type TaskResubscriptionRequest struct { + + + + // The parameters identifying the task to resubscribe to. + Params TaskIdParams +} + + + +type TaskState string + +const TaskStateAuthRequired TaskState = "auth-required" +const TaskStateCanceled TaskState = "canceled" +const TaskStateCompleted TaskState = "completed" +const TaskStateFailed TaskState = "failed" +const TaskStateInputRequired TaskState = "input-required" +const TaskStateRejected TaskState = "rejected" +const TaskStateSubmitted TaskState = "submitted" +const TaskStateUnknown TaskState = "unknown" +const TaskStateWorking TaskState = "working" + + + + +// Represents the status of a task at a specific point in time. +type TaskStatus struct { + // An optional, human-readable message providing more details about the current + // status. + Message *Message + + // The current state of the task's lifecycle. + State TaskState + + // An ISO 8601 datetime string indicating when this status was recorded. + Timestamp *string +} + +// An event sent by the agent to notify the client of a change in a task's status. +// This is typically used in streaming or subscription models. +type TaskStatusUpdateEvent struct { + // The context ID associated with the task. + ContextId string + + // If true, this is the final event in the stream for this interaction. + Final bool + + // The type of this event, used as a discriminator. Always 'status-update'. + Kind string + + // Optional metadata for extensions. + Metadata map[string]any + + // The new status of the task. + Status TaskStatus + + // The ID of the task that was updated. + TaskId string +} + + + + +// An A2A-specific error indicating that the requested operation is not supported +// by the agent. +type UnsupportedOperationError struct { + // The error code for an unsupported operation. + Code int + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data any + + // The error message. + Message string +} + + + + +// Represents a text segment within a message or artifact. +type TextPart struct { + // The type of this part, used as a discriminator. Always 'text'. + Kind string + + // Optional metadata associated with this part. + Metadata map[string]any + + // The string content of the text part. + Text string +} + + + +type TransportProtocol string + + + + +const TransportProtocolJSONRPC TransportProtocol = "JSONRPC" +const TransportProtocolGRPC TransportProtocol = "GRPC" +const TransportProtocolHTTPJSON TransportProtocol = "HTTP+JSON" diff --git a/tools/jsonrpc2spec.go b/tools/jsonrpc2spec.go new file mode 100644 index 00000000..1ccd75e5 --- /dev/null +++ b/tools/jsonrpc2spec.go @@ -0,0 +1,171 @@ +// Sanitizes proto-gener + +package main + +import ( + "bufio" + "flag" + "fmt" + "io" + "os" + "strings" +) + +func main() { + inPath := flag.String("in", "./internal/jsonrpc/spec.go", "path to json-schema file") + outPath := flag.String("out", "./a2a/types.go", "path to .go file with type definitions") + flag.Parse() + + inFile, err := os.Open(*inPath) + if err != nil { + fmt.Printf("Failed to open input file: %v\n", err) + os.Exit(1) + } + defer inFile.Close() + + converted, err := protoToStruct(inFile) + if err != nil { + fmt.Printf("Error: %v\n", err) + os.Exit(1) + } + + if err := os.WriteFile(*outPath, []byte(converted), 0644); err != nil { + fmt.Printf("Failed to write converted string to %s: %v\n", *outPath, err) + os.Exit(1) + } + + fmt.Printf("Successfully converted %s to %s\n", *inPath, *outPath) +} + +func protoToStruct(in io.Reader) (string, error) { + s := bufio.NewScanner(in) + + var result strings.Builder + + for s.Scan() { + line := s.Text() + + line = handleReplacements(line) + + if strings.HasPrefix(line, "import ") { + continue + } + + if strings.HasPrefix(line, "func ") || strings.HasPrefix(line, "var ") { + if err := skipPkgLevelBlock(s); err != nil { + return "", err + } + continue + } + + if !strings.HasPrefix(line, "type ") { + writeLine(&result, line) + continue + } + + handleStruct(s, line, &result) + } + + return result.String(), nil +} + +func handleStruct(s *bufio.Scanner, line string, result *strings.Builder) error { + if strings.Contains(line, " = ") { + return skipPkgLevelBlock(s) + } + + if !strings.HasSuffix(line, "{") { + writeLine(result, line) + return nil + } + + writeLine(result, line) + + if strings.Contains(line, "interface{}") { + return nil + } + + text, err := consumeStruct(s) + if err != nil { + return err + } + + result.WriteString(text) + return nil +} + +func consumeStruct(s *bufio.Scanner) (string, error) { + var b strings.Builder + + for s.Scan() { + line := s.Text() + + if shouldSkipStructLine(line) { + continue + } + + line = handleReplacements(line) + + if line == "}" { + writeLine(&b, line) + return b.String(), nil + } + + if tagStart := strings.IndexRune(line, '`'); tagStart >= 0 { + writeLine(&b, line[:tagStart-1]) + continue + } + + writeLine(&b, line) + } + return "", fmt.Errorf("unexpected EOF while skipping func") +} + +func shouldSkipStructLine(line string) bool { + prefixBlacklist := []string{ + "// The version of the JSON-RPC protocol. MUST be exactly", + "Jsonrpc string `json:", + "// The method name. Must be ", + "Method string `json:", + "// The identifier for this request.", + "// The identifier established by the client.", + "Id interface{}", + } + trimmed := strings.TrimSpace(line) + for _, p := range prefixBlacklist { + if strings.HasPrefix(trimmed, p) { + return true + } + } + return false +} + +func handleReplacements(line string) string { + replace := map[string]string{ + "Url": "URL", + "interface{}": "any", + "JSON-RPC response": "response", + "JSON-RPC request": "request", + "// UnmarshalJSON implements json.Unmarshaler.": "", + } + for old, new := range replace { + if strings.Contains(line, old) { + return strings.Replace(line, old, new, 1) + } + } + return line +} + +func skipPkgLevelBlock(s *bufio.Scanner) error { + for s.Scan() { + if line := s.Text(); line == "}" || line == ")" { + return nil + } + } + return fmt.Errorf("unexpected EOF while skipping pkg level block") +} + +func writeLine(sb *strings.Builder, line string) { + sb.WriteString(line) + sb.WriteByte('\n') +} From 200912df44954a0bef25069ba037f4ef1f4a0057 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Wed, 6 Aug 2025 15:53:17 +0000 Subject: [PATCH 03/23] manual cleanup of generated types --- a2a/errors.go | 17 ++ a2a/types.go | 789 +++++++------------------------------------------- 2 files changed, 122 insertions(+), 684 deletions(-) create mode 100644 a2a/errors.go diff --git a/a2a/errors.go b/a2a/errors.go new file mode 100644 index 00000000..8b4bdb67 --- /dev/null +++ b/a2a/errors.go @@ -0,0 +1,17 @@ +package a2a + +import "fmt" + +var ErrTaskNotFound = fmt.Errorf("task not found") + +var ErrTaskNotCancelable = fmt.Errorf("task cannot be canceled") + +var ErrPushNotificationNotSupported = fmt.Errorf("push notification not supported") + +var ErrUnsupportedOperation = fmt.Errorf("this operation is not supported") + +var ErrUnsupportedContentType = fmt.Errorf("incompatible content types") + +var ErrInvalidAgentResponse = fmt.Errorf("invalid agent response") + +var ErrInvalidRequest = fmt.Errorf("invalid request") diff --git a/a2a/types.go b/a2a/types.go index ddc66754..e24ffbc0 100644 --- a/a2a/types.go +++ b/a2a/types.go @@ -1,14 +1,4 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package jsonrpc - - -// A discriminated union of all standard JSON-RPC and A2A-specific error types. -type A2AError any - -// A discriminated union representing all possible JSON-RPC 2.0 requests supported -// by the A2A specification. -type A2ARequest any +package a2a // Defines a security scheme using an API key. type APIKeySecurityScheme struct { @@ -27,14 +17,11 @@ type APIKeySecurityScheme struct { type APIKeySecuritySchemeIn string -const APIKeySecuritySchemeInCookie APIKeySecuritySchemeIn = "cookie" -const APIKeySecuritySchemeInHeader APIKeySecuritySchemeIn = "header" -const APIKeySecuritySchemeInQuery APIKeySecuritySchemeIn = "query" - - - - - +const ( + APIKeySecuritySchemeInCookie APIKeySecuritySchemeIn = "cookie" + APIKeySecuritySchemeInHeader APIKeySecuritySchemeIn = "header" + APIKeySecuritySchemeInQuery APIKeySecuritySchemeIn = "query" +) // Defines optional capabilities supported by an agent. type AgentCapabilities struct { @@ -160,10 +147,6 @@ type AgentCardSignature struct { Signature string } - - - - // A declaration of a protocol extension supported by an Agent. type AgentExtension struct { // A human-readable description of how this agent uses the extension. @@ -181,8 +164,6 @@ type AgentExtension struct { Uri string } - - // Declares a combination of a target URL and a transport protocol for interacting // with the agent. // This allows agents to expose the same functionality over multiple transport @@ -196,19 +177,15 @@ type AgentInterface struct { URL string } - - // Represents the service provider of an agent. type AgentProvider struct { // The name of the agent provider's organization. - Organization string + Org string // A URL for the agent provider's website or relevant documentation. URL string } - - // Represents a distinct capability or function that an agent can perform. type AgentSkill struct { // A detailed description of the skill, intended to help clients or users @@ -220,7 +197,7 @@ type AgentSkill struct { Examples []string // A unique identifier for the agent's skill. - Id string + ID string // The set of supported input MIME types for this skill, overriding the agent's // defaults. @@ -245,13 +222,11 @@ type AgentSkill struct { Tags []string } - - // Represents a file, data structure, or other resource generated by an agent // during a task. type Artifact struct { // A unique identifier for the artifact within the scope of the task. - ArtifactId string + ArtifactID string // An optional, human-readable description of the artifact. Description *string @@ -268,10 +243,7 @@ type Artifact struct { // An array of content parts that make up the artifact. Parts []ArtifactPartsElem } - -type ArtifactPartsElem any - - +type ArtifactPartsElem interface{} // An A2A-specific error indicating that the agent does not have an Authenticated // Extended Card configured @@ -288,13 +260,11 @@ type AuthenticatedExtendedCardNotConfiguredError struct { Message string } - - // Defines configuration details for the OAuth 2.0 Authorization Code flow. -type AuthorizationCodeOAuthFlow struct { +type AuthzCodeOAuthFlow struct { // The authorization URL to be used for this flow. // This MUST be a URL and use TLS. - AuthorizationURL string + AuthzURL string // The URL to be used for obtaining refresh tokens. // This MUST be a URL and use TLS. @@ -309,32 +279,18 @@ type AuthorizationCodeOAuthFlow struct { TokenURL string } - - // Represents a request for the `tasks/cancel` method. type CancelTaskRequest struct { - - - // The parameters identifying the task to cancel. - Params TaskIdParams + Params TaskIDParams } - - -// Represents a response for the `tasks/cancel` method. -type CancelTaskResponse any - // Represents a successful response for the `tasks/cancel` method. -type CancelTaskSuccessResponse struct { - - +type CancelTaskResponse struct { // The result, containing the final state of the canceled Task object. Result Task } - - // Defines configuration details for the OAuth 2.0 Client Credentials flow. type ClientCredentialsOAuthFlow struct { // The URL to be used for obtaining refresh tokens. This MUST be a URL. @@ -348,25 +304,6 @@ type ClientCredentialsOAuthFlow struct { TokenURL string } - - -// An A2A-specific error indicating an incompatibility between the requested -// content types and the agent's capabilities. -type ContentTypeNotSupportedError struct { - // The error code for an unsupported content type. - Code int - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data any - - // The error message. - Message string -} - - - // Represents a structured data segment (e.g., JSON) within a message or artifact. type DataPart struct { // The structured data content. @@ -379,50 +316,32 @@ type DataPart struct { Metadata map[string]any } - - // Defines parameters for deleting a specific push notification configuration for a // task. type DeleteTaskPushNotificationConfigParams struct { // The unique identifier of the task. - Id string + ID string // Optional metadata associated with the request. Metadata map[string]any // The ID of the push notification configuration to delete. - PushNotificationConfigId string + PushNotificationConfigID string } - - // Represents a request for the `tasks/pushNotificationConfig/delete` // method. type DeleteTaskPushNotificationConfigRequest struct { - - - // The parameters identifying the push notification configuration to delete. Params DeleteTaskPushNotificationConfigParams } - - -// Represents a response for the `tasks/pushNotificationConfig/delete` -// method. -type DeleteTaskPushNotificationConfigResponse any - -// Represents a successful response for the -// `tasks/pushNotificationConfig/delete` method. -type DeleteTaskPushNotificationConfigSuccessResponse struct { - - +// Represents a successful response for the `tasks/pushNotificationConfig/delete` method. +type DeleteTaskPushNotificationConfigResponse struct { // The result is null on successful deletion. Result any } - - // Defines base properties for a file. type FileBase struct { // The MIME type of the file (e.g., "application/pdf"). @@ -460,10 +379,6 @@ type FilePartFile struct { Uri string } - - - - // Represents a file with its content provided directly as a base64-encoded string. type FileWithBytes struct { // The base64-encoded content of the file. @@ -476,8 +391,6 @@ type FileWithBytes struct { Name *string } - - // Represents a file with its content located at a specific URI. type FileWithUri struct { // The MIME type of the file (e.g., "application/pdf"). @@ -490,52 +403,26 @@ type FileWithUri struct { Uri string } - - -// Represents a request for the `agent/getAuthenticatedExtendedCard` -// method. -type GetAuthenticatedExtendedCardRequest struct { - - -} - - - -// Represents a response for the `agent/getAuthenticatedExtendedCard` -// method. -type GetAuthenticatedExtendedCardResponse any - -// Represents a successful response for the -// `agent/getAuthenticatedExtendedCard` method. -type GetAuthenticatedExtendedCardSuccessResponse struct { - - +// Represents a successful response for the `agent/getAuthenticatedExtendedCard` method. +type GetAuthenticatedExtendedCardResponse struct { // The result is an Agent Card object. Result AgentCard } - - -// Defines parameters for fetching a specific push notification configuration for a -// task. +// Defines parameters for fetching a specific push notification configuration for a task. type GetTaskPushNotificationConfigParams struct { // The unique identifier of the task. - Id string + ID string // Optional metadata associated with the request. Metadata map[string]any // The ID of the push notification configuration to retrieve. - PushNotificationConfigId *string + PushNotificationConfigID *string } - - // Represents a request for the `tasks/pushNotificationConfig/get` method. type GetTaskPushNotificationConfigRequest struct { - - - // The parameters for getting a push notification configuration. Params GetTaskPushNotificationConfigRequestParams } @@ -543,58 +430,33 @@ type GetTaskPushNotificationConfigRequest struct { // Defines parameters containing a task ID, used for simple task operations. type GetTaskPushNotificationConfigRequestParams struct { // The unique identifier of the task. - Id string + ID string // Optional metadata associated with the request. Metadata map[string]any // The ID of the push notification configuration to retrieve. - PushNotificationConfigId *string + PushNotificationConfigID *string } - - - - -// Represents a response for the `tasks/pushNotificationConfig/get` -// method. -type GetTaskPushNotificationConfigResponse any - -// Represents a successful response for the -// `tasks/pushNotificationConfig/get` method. -type GetTaskPushNotificationConfigSuccessResponse struct { - - +// Represents a response for the `tasks/pushNotificationConfig/get` method. +type GetTaskPushNotificationConfigResponse struct { // The result, containing the requested push notification configuration. - Result TaskPushNotificationConfig + Result TaskPushConfig } - - // Represents a request for the `tasks/get` method. type GetTaskRequest struct { - - - // The parameters for querying a task. Params TaskQueryParams } - - -// Represents a response for the `tasks/get` method. -type GetTaskResponse any - // Represents a successful response for the `tasks/get` method. -type GetTaskSuccessResponse struct { - - +type GetTaskResponse struct { // The result, containing the requested Task object. Result Task } - - // Defines a security scheme using HTTP authentication. type HTTPAuthSecurityScheme struct { // A hint to the client to identify how the bearer token is formatted (e.g., @@ -615,12 +477,10 @@ type HTTPAuthSecurityScheme struct { Type string } - - // Defines configuration details for the OAuth 2.0 Implicit flow. type ImplicitOAuthFlow struct { // The authorization URL to be used for this flow. This MUST be a URL. - AuthorizationURL string + AuthzURL string // The URL to be used for obtaining refresh tokens. This MUST be a URL. RefreshURL *string @@ -630,8 +490,6 @@ type ImplicitOAuthFlow struct { Scopes map[string]string } - - // An error indicating an internal error on the server. type InternalError struct { // The error code for an internal server error. @@ -646,202 +504,34 @@ type InternalError struct { Message string } - - -// An A2A-specific error indicating that the agent returned a response that -// does not conform to the specification for the current method. -type InvalidAgentResponseError struct { - // The error code for an invalid agent response. - Code int - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data any - - // The error message. - Message string -} - - - -// An error indicating that the method parameters are invalid. -type InvalidParamsError struct { - // The error code for an invalid parameters error. - Code int - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data any - - // The error message. - Message string -} - - - -// An error indicating that the JSON sent is not a valid Request object. -type InvalidRequestError struct { - // The error code for an invalid request. - Code int - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data any - - // The error message. - Message string -} - - - -// An error indicating that the server received invalid JSON. -type JSONParseError struct { - // The error code for a JSON parse error. - Code int - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data any - - // The error message. - Message string -} - - - -// Represents a JSON-RPC 2.0 Error object, included in an error response. -type JSONRPCError struct { - // A number that indicates the error type that occurred. - Code int - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data any - - // A string providing a short description of the error. - Message string -} - -// Represents a JSON-RPC 2.0 Error Response object. -type JSONRPCErrorResponse struct { - // An object describing the error that occurred. - Error JSONRPCErrorResponseError - - -} - -// Represents a JSON-RPC 2.0 Error object, included in an error response. -type JSONRPCErrorResponseError struct { - // A number that indicates the error type that occurred. - Code int - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data any - - // A string providing a short description of the error. - Message string -} - - - - - - - -// Defines the base structure for any JSON-RPC 2.0 request, response, or -// notification. -type JSONRPCMessage struct { - // A unique identifier established by the client. It must be a String, a Number, - // or null. - // The server must reply with the same value in the response. This property is - // omitted for notifications. - -} - - - -// Represents a JSON-RPC 2.0 Request object. -type JSONRPCRequest struct { - // A unique identifier established by the client. It must be a String, a Number, - // or null. - // The server must reply with the same value in the response. This property is - // omitted for notifications. - - - // A string containing the name of the method to be invoked. - - // A structured value holding the parameter values to be used during the method - // invocation. - Params map[string]any -} - - - -// A discriminated union representing all possible JSON-RPC 2.0 responses -// for the A2A specification methods. -type JSONRPCResponse any - -// Represents a successful JSON-RPC 2.0 Response object. -type JSONRPCSuccessResponse struct { - - - // The value of this member is determined by the method invoked on the Server. - Result any -} - - - // Defines parameters for listing all push notification configurations associated // with a task. type ListTaskPushNotificationConfigParams struct { // The unique identifier of the task. - Id string + ID string // Optional metadata associated with the request. Metadata map[string]any } - - // Represents a request for the `tasks/pushNotificationConfig/list` // method. type ListTaskPushNotificationConfigRequest struct { - - - // The parameters identifying the task whose configurations are to be listed. Params ListTaskPushNotificationConfigParams } - - -// Represents a response for the `tasks/pushNotificationConfig/list` -// method. -type ListTaskPushNotificationConfigResponse any - -// Represents a successful response for the -// `tasks/pushNotificationConfig/list` method. -type ListTaskPushNotificationConfigSuccessResponse struct { - - +// Represents a response for the `tasks/pushNotificationConfig/list` method. +type ListTaskPushNotificationConfigResponse struct { // The result, containing an array of all push notification configurations for the // task. - Result []TaskPushNotificationConfig + Result []TaskPushConfig } - - // Represents a single message in the conversation between a user and an agent. type Message struct { // The context identifier for this message, used to group related interactions. - ContextId *string + ContextID *string // The URIs of extensions that are relevant to this message. Extensions []string @@ -851,7 +541,7 @@ type Message struct { Kind string // A unique identifier for the message, typically a UUID, generated by the sender. - MessageId string + MessageID string // Optional metadata for extensions. The key is an extension-specific identifier. Metadata map[string]any @@ -861,7 +551,7 @@ type Message struct { Parts []MessagePartsElem // A list of other task IDs that this message references for additional context. - ReferenceTaskIds []string + ReferenceTasks []TaskID // Identifies the sender of the message. // service. @@ -869,21 +559,19 @@ type Message struct { // The identifier of the task this message is part of. Can be omitted for the // first message of a new task. - TaskId *string + TaskID *TaskID } - -type MessagePartsElem any +type MessagePartsElem interface{} type MessageRole string -const MessageRoleAgent MessageRole = "agent" -const MessageRoleUser MessageRole = "user" - - - +const ( + MessageRoleAgent MessageRole = "agent" + MessageRoleUser MessageRole = "user" +) // Defines configuration options for a `message/send` or `message/stream` request. -type MessageSendConfiguration struct { +type MessageSendConfig struct { // A list of output MIME types the client is prepared to accept in the response. AcceptedOutputModes []string @@ -897,7 +585,7 @@ type MessageSendConfiguration struct { // Configuration for the agent to send push notifications for updates after the // initial response. - PushNotificationConfig *PushNotificationConfig + PushConfig *PushConfig } // Defines the parameters for a request to send a message to an agent. This can be @@ -905,7 +593,7 @@ type MessageSendConfiguration struct { // to create a new task, continue an existing one, or restart a task. type MessageSendParams struct { // Optional configuration for the send request. - Configuration *MessageSendConfiguration + Configuration *MessageSendConfig // The message object being sent to the agent. Message Message @@ -914,27 +602,6 @@ type MessageSendParams struct { Metadata map[string]any } - - - - -// An error indicating that the requested method does not exist or is not -// available. -type MethodNotFoundError struct { - // The error code for a method not found error. - Code int - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data any - - // The error message. - Message string -} - - - // Defines a security scheme using mTLS authentication. type MutualTLSSecurityScheme struct { // An optional description for the security scheme. @@ -944,8 +611,6 @@ type MutualTLSSecurityScheme struct { Type string } - - // Defines a security scheme using OAuth 2.0. type OAuth2SecurityScheme struct { // An optional description for the security scheme. @@ -963,13 +628,11 @@ type OAuth2SecurityScheme struct { Type string } - - // Defines the configuration for the supported OAuth 2.0 flows. type OAuthFlows struct { // Configuration for the OAuth Authorization Code flow. Previously called // accessCode in OpenAPI 2.0. - AuthorizationCode *AuthorizationCodeOAuthFlow + AuthzCode *AuthzCodeOAuthFlow // Configuration for the OAuth Client Credentials flow. Previously called // application in OpenAPI 2.0. @@ -983,22 +646,20 @@ type OAuthFlows struct { } // Defines a security scheme using OpenID Connect. -type OpenIdConnectSecurityScheme struct { +type OpenIDConnectSecurityScheme struct { // An optional description for the security scheme. Description *string // The OpenID Connect Discovery URL for the OIDC provider's metadata. - OpenIdConnectURL string + OpenIDConnectURL string - // The type of the security scheme. Must be 'openIdConnect'. + // The type of the security scheme. Must be 'openIDConnect'. Type string } - - // A discriminated union representing a part of a message or artifact, which can // be text, a file, or structured data. -type Part any +type Part interface{} // Defines base properties common to all message or artifact parts. type PartBase struct { @@ -1019,10 +680,8 @@ type PasswordOAuthFlow struct { TokenURL string } - - // Defines authentication details for a push notification endpoint. -type PushNotificationAuthenticationInfo struct { +type PushAuthInfo struct { // Optional credentials required by the push notification endpoint. Credentials *string @@ -1030,17 +689,15 @@ type PushNotificationAuthenticationInfo struct { Schemes []string } - - // Defines the configuration for setting up push notifications for task updates. -type PushNotificationConfig struct { +type PushConfig struct { // Optional authentication details for the agent to use when calling the // notification URL. - Authentication *PushNotificationAuthenticationInfo + Auth *PushAuthInfo // A unique ID for the push notification configuration, set by the client // to support multiple notification callbacks. - Id *string + ID *string // A unique token for this task or session to validate incoming push // notifications. @@ -1050,29 +707,10 @@ type PushNotificationConfig struct { URL string } - - -// An A2A-specific error indicating that the agent does not support push -// notifications. -type PushNotificationNotSupportedError struct { - // The error code for when push notifications are not supported. - Code int - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data any - - // The error message. - Message string -} - - - // Defines a security scheme that can be used to secure an agent's endpoints. // This is a discriminated union type based on the OpenAPI 3.0 Security Scheme // Object. -type SecurityScheme any +type SecurityScheme interface{} // Defines base properties shared by all security scheme objects. type SecuritySchemeBase struct { @@ -1082,193 +720,37 @@ type SecuritySchemeBase struct { // Represents a request for the `message/send` method. type SendMessageRequest struct { - - - // The parameters for sending a message. Params MessageSendParams } - - // Represents a response for the `message/send` method. -type SendMessageResponse any - -// Represents a successful response for the `message/send` method. -type SendMessageSuccessResponse struct { - - - // The result, which can be a direct reply Message or the initial Task object. - Result SendMessageSuccessResponseResult +type SendMessageResponse interface { + isSendMessageResponse() } -// Represents a single, stateful operation or conversation between a client and an -// agent. -type SendMessageSuccessResponseResult struct { - // A collection of artifacts generated by the agent during the execution of the - // task. - Artifacts []Artifact - - // A server-generated identifier for maintaining context across multiple related - // tasks or interactions. - ContextId string - - // The URIs of extensions that are relevant to this message. - Extensions []string - - // An array of messages exchanged during the task, representing the conversation - // history. - History []Message - - // A unique identifier for the task, generated by the server for a new task. - Id string - - // The type of this object, used as a discriminator. Always 'task' for a Task. - Kind string - - // A unique identifier for the message, typically a UUID, generated by the sender. - MessageId string - - // Optional metadata for extensions. The key is an extension-specific identifier. - Metadata map[string]any - - // An array of content parts that form the message body. A message can be - // composed of multiple parts of different types (e.g., text and files). - Parts []MessagePartsElem - - // A list of other task IDs that this message references for additional context. - ReferenceTaskIds []string - - // Identifies the sender of the message. - // service. - Role MessageRole - - // The current status of the task, including its state and a descriptive message. - Status TaskStatus - - // The identifier of the task this message is part of. Can be omitted for the - // first message of a new task. - TaskId *string -} - - - - +func (Task) isSendMessageResponse() {} +func (Message) isSendMessageResponse() {} // Represents a request for the `message/stream` method. type SendStreamingMessageRequest struct { - - - // The parameters for sending a message. Params MessageSendParams } - - -// Represents a response for the `message/stream` method. -type SendStreamingMessageResponse any - -// Represents a successful response for the `message/stream` method. -// The server may send multiple response objects for a single request. -type SendStreamingMessageSuccessResponse struct { - - - // The result, which can be a Message, Task, or a streaming update event. - Result SendStreamingMessageSuccessResponseResult -} - -// Represents a single, stateful operation or conversation between a client and an -// agent. -type SendStreamingMessageSuccessResponseResult struct { - // If true, the content of this artifact should be appended to a previously sent - // artifact with the same ID. - Append *bool - - // The artifact that was generated or updated. - Artifact Artifact - - // A collection of artifacts generated by the agent during the execution of the - // task. - Artifacts []Artifact - - // A server-generated identifier for maintaining context across multiple related - // tasks or interactions. - ContextId string - - // The URIs of extensions that are relevant to this message. - Extensions []string - - // If true, this is the final event in the stream for this interaction. - Final bool - - // An array of messages exchanged during the task, representing the conversation - // history. - History []Message - - // A unique identifier for the task, generated by the server for a new task. - Id string - - // The type of this object, used as a discriminator. Always 'task' for a Task. - Kind string - - // If true, this is the final chunk of the artifact. - LastChunk *bool - - // A unique identifier for the message, typically a UUID, generated by the sender. - MessageId string - - // Optional metadata for extensions. The key is an extension-specific identifier. - Metadata map[string]any - - // An array of content parts that form the message body. A message can be - // composed of multiple parts of different types (e.g., text and files). - Parts []MessagePartsElem - - // A list of other task IDs that this message references for additional context. - ReferenceTaskIds []string - - // Identifies the sender of the message. - // service. - Role MessageRole - - // The current status of the task, including its state and a descriptive message. - Status TaskStatus - - // The identifier of the task this message is part of. Can be omitted for the - // first message of a new task. - TaskId string -} - - - - - // Represents a request for the `tasks/pushNotificationConfig/set` method. -type SetTaskPushNotificationConfigRequest struct { - - - +type SetTaskPushNotificationConfigParams struct { // The parameters for setting the push notification configuration. - Params TaskPushNotificationConfig + Params TaskPushConfig } - - -// Represents a response for the `tasks/pushNotificationConfig/set` -// method. -type SetTaskPushNotificationConfigResponse any - -// Represents a successful response for the -// `tasks/pushNotificationConfig/set` method. -type SetTaskPushNotificationConfigSuccessResponse struct { - - +// Represents a response for the `tasks/pushNotificationConfig/set` method. +type SetTaskPushNotificationConfigResponse struct { // The result, containing the configured push notification settings. - Result TaskPushNotificationConfig + Result TaskPushConfig } - +type TaskID string // Represents a single, stateful operation or conversation between a client and an // agent. @@ -1279,14 +761,14 @@ type Task struct { // A server-generated identifier for maintaining context across multiple related // tasks or interactions. - ContextId string + ContextID string // An array of messages exchanged during the task, representing the conversation // history. History []Message // A unique identifier for the task, generated by the server for a new task. - Id string + ID TaskID // The type of this object, used as a discriminator. Always 'task' for a Task. Kind string @@ -1309,7 +791,7 @@ type TaskArtifactUpdateEvent struct { Artifact Artifact // The context ID associated with the task. - ContextId string + ContextID string // The type of this event, used as a discriminator. Always 'artifact-update'. Kind string @@ -1321,106 +803,59 @@ type TaskArtifactUpdateEvent struct { Metadata map[string]any // The ID of the task this artifact belongs to. - TaskId string + TaskID TaskID } - - // Defines parameters containing a task ID, used for simple task operations. -type TaskIdParams struct { +type TaskIDParams struct { // The unique identifier of the task. - Id string + ID TaskID // Optional metadata associated with the request. Metadata map[string]any } - - -// An A2A-specific error indicating that the task is in a state where it cannot be -// canceled. -type TaskNotCancelableError struct { - // The error code for a task that cannot be canceled. - Code int - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data any - - // The error message. - Message string -} - - - -// An A2A-specific error indicating that the requested task ID was not found. -type TaskNotFoundError struct { - // The error code for a task not found error. - Code int - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data any - - // The error message. - Message string -} - - - // A container associating a push notification configuration with a specific task. -type TaskPushNotificationConfig struct { +type TaskPushConfig struct { // The push notification configuration for this task. - PushNotificationConfig PushNotificationConfig + PushConfig PushConfig // The ID of the task. - TaskId string + TaskID TaskID } - - // Defines parameters for querying a task, with an option to limit history length. type TaskQueryParams struct { // The number of most recent messages from the task's history to retrieve. HistoryLength *int // The unique identifier of the task. - Id string + ID TaskID // Optional metadata associated with the request. Metadata map[string]any } - - // Represents a request for the `tasks/resubscribe` method, used to resume // a streaming connection. type TaskResubscriptionRequest struct { - - - // The parameters identifying the task to resubscribe to. - Params TaskIdParams + Params TaskIDParams } - - type TaskState string -const TaskStateAuthRequired TaskState = "auth-required" -const TaskStateCanceled TaskState = "canceled" -const TaskStateCompleted TaskState = "completed" -const TaskStateFailed TaskState = "failed" -const TaskStateInputRequired TaskState = "input-required" -const TaskStateRejected TaskState = "rejected" -const TaskStateSubmitted TaskState = "submitted" -const TaskStateUnknown TaskState = "unknown" -const TaskStateWorking TaskState = "working" - - - +const ( + TaskStateAuthRequired TaskState = "auth-required" + TaskStateCanceled TaskState = "canceled" + TaskStateCompleted TaskState = "completed" + TaskStateFailed TaskState = "failed" + TaskStateInputRequired TaskState = "input-required" + TaskStateRejected TaskState = "rejected" + TaskStateSubmitted TaskState = "submitted" + TaskStateUnknown TaskState = "unknown" + TaskStateWorking TaskState = "working" +) // Represents the status of a task at a specific point in time. type TaskStatus struct { @@ -1435,11 +870,21 @@ type TaskStatus struct { Timestamp *string } +// Event interface is used to represent types that can be sent over a streaming connection. +type Event interface { + isEvent() +} + +func (t Task) isEvent() {} +func (t Message) isEvent() {} +func (t TaskStatusUpdateEvent) isEvent() {} +func (t TaskArtifactUpdateEvent) isEvent() {} + // An event sent by the agent to notify the client of a change in a task's status. // This is typically used in streaming or subscription models. type TaskStatusUpdateEvent struct { // The context ID associated with the task. - ContextId string + ContextID string // If true, this is the final event in the stream for this interaction. Final bool @@ -1454,30 +899,9 @@ type TaskStatusUpdateEvent struct { Status TaskStatus // The ID of the task that was updated. - TaskId string -} - - - - -// An A2A-specific error indicating that the requested operation is not supported -// by the agent. -type UnsupportedOperationError struct { - // The error code for an unsupported operation. - Code int - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data any - - // The error message. - Message string + TaskID TaskID } - - - // Represents a text segment within a message or artifact. type TextPart struct { // The type of this part, used as a discriminator. Always 'text'. @@ -1490,13 +914,10 @@ type TextPart struct { Text string } - - type TransportProtocol string - - - -const TransportProtocolJSONRPC TransportProtocol = "JSONRPC" -const TransportProtocolGRPC TransportProtocol = "GRPC" -const TransportProtocolHTTPJSON TransportProtocol = "HTTP+JSON" +const ( + TransportProtocolJSONRPC TransportProtocol = "JSONRPC" + TransportProtocolGRPC TransportProtocol = "GRPC" + TransportProtocolHTTPJSON TransportProtocol = "HTTP+JSON" +) From 473c0d2c34bf8fdbf39a5874ef4e4133435fdfb1 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Wed, 6 Aug 2025 15:53:42 +0000 Subject: [PATCH 04/23] server interfaces --- a2asrv/agent.go | 16 ++++++++++++++++ a2asrv/events.go | 27 +++++++++++++++++++++++++++ a2asrv/handler.go | 27 +++++++++++++++++++++++++++ a2asrv/reqctx.go | 3 +++ a2asrv/tasks.go | 28 ++++++++++++++++++++++++++++ 5 files changed, 101 insertions(+) create mode 100644 a2asrv/agent.go create mode 100644 a2asrv/events.go create mode 100644 a2asrv/handler.go create mode 100644 a2asrv/reqctx.go create mode 100644 a2asrv/tasks.go diff --git a/a2asrv/agent.go b/a2asrv/agent.go new file mode 100644 index 00000000..84a4e907 --- /dev/null +++ b/a2asrv/agent.go @@ -0,0 +1,16 @@ +package a2asrv + +import ( + "context" + "github.com/a2aproject/a2a-go/a2a" +) + +type AgentExecutor interface { + Execute(ctx context.Context, reqCtx RequestContext, queue EventQueue) error + + Cancel(ctx context.Context, reqCtx RequestContext, queue EventQueue) error +} + +type AgentCardProducer interface { + Card() a2a.AgentCard +} diff --git a/a2asrv/events.go b/a2asrv/events.go new file mode 100644 index 00000000..c76d9aae --- /dev/null +++ b/a2asrv/events.go @@ -0,0 +1,27 @@ +package a2asrv + +import ( + "context" + "github.com/a2aproject/a2a-go/a2a" +) + +type EventWriter interface { + Write(ctx context.Context, event a2a.Event) error +} + +type EventReader interface { + Read(ctx context.Context) (a2a.Event, error) +} + +type EventQueue interface { + EventWriter + EventReader + + Close() +} + +type EventQueueManager interface { + GetOrCreate(ctx context.Context, taskId a2a.TaskID) (EventQueue, error) + + Destroy(ctx context.Context, taskId a2a.TaskID) error +} diff --git a/a2asrv/handler.go b/a2asrv/handler.go new file mode 100644 index 00000000..2b1e7912 --- /dev/null +++ b/a2asrv/handler.go @@ -0,0 +1,27 @@ +package a2asrv + +import ( + "context" + + "github.com/a2aproject/a2a-go/a2a" +) + +type RequestHandler interface { + OnHandleGetTask(ctx context.Context, query a2a.TaskQueryParams) (a2a.Task, error) + + OnHandleCancelTask(ctx context.Context, id a2a.TaskIDParams) (a2a.CancelTaskResponse, error) + + OnHandleSendMessage(ctx context.Context, message a2a.MessageSendParams) (a2a.SendMessageResponse, error) + + OnHandleResubscribeToTask(ctx context.Context, id a2a.TaskIDParams) (<-chan a2a.Event, error) + + OnHandleSendMessageStream(ctx context.Context, message a2a.MessageSendParams) (<-chan a2a.Event, error) + + OnHandleGetTaskPushConfig(ctx context.Context, params a2a.GetTaskPushNotificationConfigParams) (a2a.GetTaskPushNotificationConfigResponse, error) + + OnHandleListTaskPushConfig(ctx context.Context, params a2a.ListTaskPushNotificationConfigParams) (a2a.ListTaskPushNotificationConfigResponse, error) + + OnHandleSetTaskPushConfig(ctx context.Context, params a2a.SetTaskPushNotificationConfigParams) (a2a.SetTaskPushNotificationConfigResponse, error) + + OnHandleDeleteTaskPushConfig(ctx context.Context, params a2a.DeleteTaskPushNotificationConfigParams) (a2a.DeleteTaskPushNotificationConfigResponse, error) +} diff --git a/a2asrv/reqctx.go b/a2asrv/reqctx.go new file mode 100644 index 00000000..57b12a12 --- /dev/null +++ b/a2asrv/reqctx.go @@ -0,0 +1,3 @@ +package a2asrv + +type RequestContext struct{} diff --git a/a2asrv/tasks.go b/a2asrv/tasks.go new file mode 100644 index 00000000..63a14f1f --- /dev/null +++ b/a2asrv/tasks.go @@ -0,0 +1,28 @@ +package a2asrv + +import ( + "context" + "github.com/a2aproject/a2a-go/a2a" +) + +type RequestContextBuilder interface { + Build(ctx context.Context, p a2a.MessageSendParams, t *a2a.Task) RequestContext +} + +type PushNotifier interface { + SendPush(ctx context.Context, task a2a.Task) error +} + +type PushConfigStore interface { + Save(ctx context.Context, taskId a2a.TaskID, config a2a.PushConfig) error + + Get(ctx context.Context, taskId a2a.TaskID) ([]a2a.PushConfig, error) + + Delete(ctx context.Context, taskId a2a.TaskID) error +} + +type TaskStore interface { + Save(ctx context.Context, task a2a.Task) error + + Get(ctx context.Context, taskId a2a.TaskID) (a2a.Task, error) +} From 3195915276588570fa191dc6682989908d56764a Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Wed, 6 Aug 2025 15:54:06 +0000 Subject: [PATCH 05/23] core type dummies --- internal/events/queue.go | 3 + internal/jsonrpc/spec.go | 3384 ++++++++++++++++++++++++++++++++++++++ internal/push/sender.go | 3 + internal/push/store.go | 3 + internal/task/store.go | 3 + 5 files changed, 3396 insertions(+) create mode 100644 internal/events/queue.go create mode 100644 internal/jsonrpc/spec.go create mode 100644 internal/push/sender.go create mode 100644 internal/push/store.go create mode 100644 internal/task/store.go diff --git a/internal/events/queue.go b/internal/events/queue.go new file mode 100644 index 00000000..817633fb --- /dev/null +++ b/internal/events/queue.go @@ -0,0 +1,3 @@ +package events + +type InMemoryQueueManager struct{} diff --git a/internal/jsonrpc/spec.go b/internal/jsonrpc/spec.go new file mode 100644 index 00000000..b1113076 --- /dev/null +++ b/internal/jsonrpc/spec.go @@ -0,0 +1,3384 @@ +// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. + +package jsonrpc + +import "encoding/json" +import "errors" +import "fmt" +import "reflect" + +// A discriminated union of all standard JSON-RPC and A2A-specific error types. +type A2AError interface{} + +// A discriminated union representing all possible JSON-RPC 2.0 requests supported +// by the A2A specification. +type A2ARequest interface{} + +// Defines a security scheme using an API key. +type APIKeySecurityScheme struct { + // An optional description for the security scheme. + Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` + + // The location of the API key. + In APIKeySecuritySchemeIn `json:"in" yaml:"in" mapstructure:"in"` + + // The name of the header, query, or cookie parameter to be used. + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // The type of the security scheme. Must be 'apiKey'. + Type string `json:"type" yaml:"type" mapstructure:"type"` +} + +type APIKeySecuritySchemeIn string + +const APIKeySecuritySchemeInCookie APIKeySecuritySchemeIn = "cookie" +const APIKeySecuritySchemeInHeader APIKeySecuritySchemeIn = "header" +const APIKeySecuritySchemeInQuery APIKeySecuritySchemeIn = "query" + +var enumValues_APIKeySecuritySchemeIn = []interface{}{ + "cookie", + "header", + "query", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *APIKeySecuritySchemeIn) UnmarshalJSON(value []byte) error { + var v string + if err := json.Unmarshal(value, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_APIKeySecuritySchemeIn { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_APIKeySecuritySchemeIn, v) + } + *j = APIKeySecuritySchemeIn(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *APIKeySecurityScheme) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["in"]; raw != nil && !ok { + return fmt.Errorf("field in in APIKeySecurityScheme: required") + } + if _, ok := raw["name"]; raw != nil && !ok { + return fmt.Errorf("field name in APIKeySecurityScheme: required") + } + if _, ok := raw["type"]; raw != nil && !ok { + return fmt.Errorf("field type in APIKeySecurityScheme: required") + } + type Plain APIKeySecurityScheme + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = APIKeySecurityScheme(plain) + return nil +} + +// Defines optional capabilities supported by an agent. +type AgentCapabilities struct { + // A list of protocol extensions supported by the agent. + Extensions []AgentExtension `json:"extensions,omitempty" yaml:"extensions,omitempty" mapstructure:"extensions,omitempty"` + + // Indicates if the agent supports sending push notifications for asynchronous + // task updates. + PushNotifications *bool `json:"pushNotifications,omitempty" yaml:"pushNotifications,omitempty" mapstructure:"pushNotifications,omitempty"` + + // Indicates if the agent provides a history of state transitions for a task. + StateTransitionHistory *bool `json:"stateTransitionHistory,omitempty" yaml:"stateTransitionHistory,omitempty" mapstructure:"stateTransitionHistory,omitempty"` + + // Indicates if the agent supports Server-Sent Events (SSE) for streaming + // responses. + Streaming *bool `json:"streaming,omitempty" yaml:"streaming,omitempty" mapstructure:"streaming,omitempty"` +} + +// The AgentCard is a self-describing manifest for an agent. It provides essential +// metadata including the agent's identity, capabilities, skills, supported +// communication methods, and security requirements. +type AgentCard struct { + // A list of additional supported interfaces (transport and URL combinations). + // This allows agents to expose multiple transports, potentially at different + // URLs. + // + // Best practices: + // - SHOULD include all supported transports for completeness + // - SHOULD include an entry matching the main 'url' and 'preferredTransport' + // - MAY reuse URLs if multiple transports are available at the same endpoint + // - MUST accurately declare the transport available at each URL + // + // Clients can select any interface from this list based on their transport + // capabilities + // and preferences. This enables transport negotiation and fallback scenarios. + AdditionalInterfaces []AgentInterface `json:"additionalInterfaces,omitempty" yaml:"additionalInterfaces,omitempty" mapstructure:"additionalInterfaces,omitempty"` + + // A declaration of optional capabilities supported by the agent. + Capabilities AgentCapabilities `json:"capabilities" yaml:"capabilities" mapstructure:"capabilities"` + + // Default set of supported input MIME types for all skills, which can be + // overridden on a per-skill basis. + DefaultInputModes []string `json:"defaultInputModes" yaml:"defaultInputModes" mapstructure:"defaultInputModes"` + + // Default set of supported output MIME types for all skills, which can be + // overridden on a per-skill basis. + DefaultOutputModes []string `json:"defaultOutputModes" yaml:"defaultOutputModes" mapstructure:"defaultOutputModes"` + + // A human-readable description of the agent, assisting users and other agents + // in understanding its purpose. + Description string `json:"description" yaml:"description" mapstructure:"description"` + + // An optional URL to the agent's documentation. + DocumentationUrl *string `json:"documentationUrl,omitempty" yaml:"documentationUrl,omitempty" mapstructure:"documentationUrl,omitempty"` + + // An optional URL to an icon for the agent. + IconUrl *string `json:"iconUrl,omitempty" yaml:"iconUrl,omitempty" mapstructure:"iconUrl,omitempty"` + + // A human-readable name for the agent. + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // The transport protocol for the preferred endpoint (the main 'url' field). + // If not specified, defaults to 'JSONRPC'. + // + // IMPORTANT: The transport specified here MUST be available at the main 'url'. + // This creates a binding between the main URL and its supported transport + // protocol. + // Clients should prefer this transport and URL combination when both are + // supported. + PreferredTransport string `json:"preferredTransport,omitempty" yaml:"preferredTransport,omitempty" mapstructure:"preferredTransport,omitempty"` + + // The version of the A2A protocol this agent supports. + ProtocolVersion string `json:"protocolVersion" yaml:"protocolVersion" mapstructure:"protocolVersion"` + + // Information about the agent's service provider. + Provider *AgentProvider `json:"provider,omitempty" yaml:"provider,omitempty" mapstructure:"provider,omitempty"` + + // A list of security requirement objects that apply to all agent interactions. + // Each object + // lists security schemes that can be used. Follows the OpenAPI 3.0 Security + // Requirement Object. + // This list can be seen as an OR of ANDs. Each object in the list describes one + // possible + // set of security requirements that must be present on a request. This allows + // specifying, + // for example, "callers must either use OAuth OR an API Key AND mTLS." + Security []map[string][]string `json:"security,omitempty" yaml:"security,omitempty" mapstructure:"security,omitempty"` + + // A declaration of the security schemes available to authorize requests. The key + // is the + // scheme name. Follows the OpenAPI 3.0 Security Scheme Object. + SecuritySchemes map[string]interface{} `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty" mapstructure:"securitySchemes,omitempty"` + + // JSON Web Signatures computed for this AgentCard. + Signatures []AgentCardSignature `json:"signatures,omitempty" yaml:"signatures,omitempty" mapstructure:"signatures,omitempty"` + + // The set of skills, or distinct capabilities, that the agent can perform. + Skills []AgentSkill `json:"skills" yaml:"skills" mapstructure:"skills"` + + // If true, the agent can provide an extended agent card with additional details + // to authenticated users. Defaults to false. + SupportsAuthenticatedExtendedCard *bool `json:"supportsAuthenticatedExtendedCard,omitempty" yaml:"supportsAuthenticatedExtendedCard,omitempty" mapstructure:"supportsAuthenticatedExtendedCard,omitempty"` + + // The preferred endpoint URL for interacting with the agent. + // This URL MUST support the transport specified by 'preferredTransport'. + Url string `json:"url" yaml:"url" mapstructure:"url"` + + // The agent's own version number. The format is defined by the provider. + Version string `json:"version" yaml:"version" mapstructure:"version"` +} + +// AgentCardSignature represents a JWS signature of an AgentCard. +// This follows the JSON format of an RFC 7515 JSON Web Signature (JWS). +type AgentCardSignature struct { + // The unprotected JWS header values. + Header map[string]interface{} `json:"header,omitempty" yaml:"header,omitempty" mapstructure:"header,omitempty"` + + // The protected JWS header for the signature. This is a Base64url-encoded + // JSON object, as per RFC 7515. + Protected string `json:"protected" yaml:"protected" mapstructure:"protected"` + + // The computed signature, Base64url-encoded. + Signature string `json:"signature" yaml:"signature" mapstructure:"signature"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *AgentCardSignature) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["protected"]; raw != nil && !ok { + return fmt.Errorf("field protected in AgentCardSignature: required") + } + if _, ok := raw["signature"]; raw != nil && !ok { + return fmt.Errorf("field signature in AgentCardSignature: required") + } + type Plain AgentCardSignature + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = AgentCardSignature(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *AgentCard) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["capabilities"]; raw != nil && !ok { + return fmt.Errorf("field capabilities in AgentCard: required") + } + if _, ok := raw["defaultInputModes"]; raw != nil && !ok { + return fmt.Errorf("field defaultInputModes in AgentCard: required") + } + if _, ok := raw["defaultOutputModes"]; raw != nil && !ok { + return fmt.Errorf("field defaultOutputModes in AgentCard: required") + } + if _, ok := raw["description"]; raw != nil && !ok { + return fmt.Errorf("field description in AgentCard: required") + } + if _, ok := raw["name"]; raw != nil && !ok { + return fmt.Errorf("field name in AgentCard: required") + } + if _, ok := raw["skills"]; raw != nil && !ok { + return fmt.Errorf("field skills in AgentCard: required") + } + if _, ok := raw["url"]; raw != nil && !ok { + return fmt.Errorf("field url in AgentCard: required") + } + if _, ok := raw["version"]; raw != nil && !ok { + return fmt.Errorf("field version in AgentCard: required") + } + type Plain AgentCard + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + if v, ok := raw["preferredTransport"]; !ok || v == nil { + plain.PreferredTransport = "JSONRPC" + } + if v, ok := raw["protocolVersion"]; !ok || v == nil { + plain.ProtocolVersion = "0.3.0" + } + *j = AgentCard(plain) + return nil +} + +// A declaration of a protocol extension supported by an Agent. +type AgentExtension struct { + // A human-readable description of how this agent uses the extension. + Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` + + // Optional, extension-specific configuration parameters. + Params map[string]interface{} `json:"params,omitempty" yaml:"params,omitempty" mapstructure:"params,omitempty"` + + // If true, the client must understand and comply with the extension's + // requirements + // to interact with the agent. + Required *bool `json:"required,omitempty" yaml:"required,omitempty" mapstructure:"required,omitempty"` + + // The unique URI identifying the extension. + Uri string `json:"uri" yaml:"uri" mapstructure:"uri"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *AgentExtension) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["uri"]; raw != nil && !ok { + return fmt.Errorf("field uri in AgentExtension: required") + } + type Plain AgentExtension + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = AgentExtension(plain) + return nil +} + +// Declares a combination of a target URL and a transport protocol for interacting +// with the agent. +// This allows agents to expose the same functionality over multiple transport +// mechanisms. +type AgentInterface struct { + // The transport protocol supported at this URL. + Transport string `json:"transport" yaml:"transport" mapstructure:"transport"` + + // The URL where this interface is available. Must be a valid absolute HTTPS URL + // in production. + Url string `json:"url" yaml:"url" mapstructure:"url"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *AgentInterface) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["transport"]; raw != nil && !ok { + return fmt.Errorf("field transport in AgentInterface: required") + } + if _, ok := raw["url"]; raw != nil && !ok { + return fmt.Errorf("field url in AgentInterface: required") + } + type Plain AgentInterface + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = AgentInterface(plain) + return nil +} + +// Represents the service provider of an agent. +type AgentProvider struct { + // The name of the agent provider's organization. + Organization string `json:"organization" yaml:"organization" mapstructure:"organization"` + + // A URL for the agent provider's website or relevant documentation. + Url string `json:"url" yaml:"url" mapstructure:"url"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *AgentProvider) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["organization"]; raw != nil && !ok { + return fmt.Errorf("field organization in AgentProvider: required") + } + if _, ok := raw["url"]; raw != nil && !ok { + return fmt.Errorf("field url in AgentProvider: required") + } + type Plain AgentProvider + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = AgentProvider(plain) + return nil +} + +// Represents a distinct capability or function that an agent can perform. +type AgentSkill struct { + // A detailed description of the skill, intended to help clients or users + // understand its purpose and functionality. + Description string `json:"description" yaml:"description" mapstructure:"description"` + + // Example prompts or scenarios that this skill can handle. Provides a hint to + // the client on how to use the skill. + Examples []string `json:"examples,omitempty" yaml:"examples,omitempty" mapstructure:"examples,omitempty"` + + // A unique identifier for the agent's skill. + Id string `json:"id" yaml:"id" mapstructure:"id"` + + // The set of supported input MIME types for this skill, overriding the agent's + // defaults. + InputModes []string `json:"inputModes,omitempty" yaml:"inputModes,omitempty" mapstructure:"inputModes,omitempty"` + + // A human-readable name for the skill. + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // The set of supported output MIME types for this skill, overriding the agent's + // defaults. + OutputModes []string `json:"outputModes,omitempty" yaml:"outputModes,omitempty" mapstructure:"outputModes,omitempty"` + + // Security schemes necessary for the agent to leverage this skill. + // As in the overall AgentCard.security, this list represents a logical OR of + // security + // requirement objects. Each object is a set of security schemes that must be used + // together + // (a logical AND). + Security []map[string][]string `json:"security,omitempty" yaml:"security,omitempty" mapstructure:"security,omitempty"` + + // A set of keywords describing the skill's capabilities. + Tags []string `json:"tags" yaml:"tags" mapstructure:"tags"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *AgentSkill) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["description"]; raw != nil && !ok { + return fmt.Errorf("field description in AgentSkill: required") + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in AgentSkill: required") + } + if _, ok := raw["name"]; raw != nil && !ok { + return fmt.Errorf("field name in AgentSkill: required") + } + if _, ok := raw["tags"]; raw != nil && !ok { + return fmt.Errorf("field tags in AgentSkill: required") + } + type Plain AgentSkill + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = AgentSkill(plain) + return nil +} + +// Represents a file, data structure, or other resource generated by an agent +// during a task. +type Artifact struct { + // A unique identifier for the artifact within the scope of the task. + ArtifactId string `json:"artifactId" yaml:"artifactId" mapstructure:"artifactId"` + + // An optional, human-readable description of the artifact. + Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` + + // The URIs of extensions that are relevant to this artifact. + Extensions []string `json:"extensions,omitempty" yaml:"extensions,omitempty" mapstructure:"extensions,omitempty"` + + // Optional metadata for extensions. The key is an extension-specific identifier. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` + + // An optional, human-readable name for the artifact. + Name *string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty"` + + // An array of content parts that make up the artifact. + Parts []ArtifactPartsElem `json:"parts" yaml:"parts" mapstructure:"parts"` +} + +type ArtifactPartsElem interface{} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *Artifact) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["artifactId"]; raw != nil && !ok { + return fmt.Errorf("field artifactId in Artifact: required") + } + if _, ok := raw["parts"]; raw != nil && !ok { + return fmt.Errorf("field parts in Artifact: required") + } + type Plain Artifact + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = Artifact(plain) + return nil +} + +// An A2A-specific error indicating that the agent does not have an Authenticated +// Extended Card configured +type AuthenticatedExtendedCardNotConfiguredError struct { + // The error code for when an authenticated extended card is not configured. + Code int `json:"code" yaml:"code" mapstructure:"code"` + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` + + // The error message. + Message string `json:"message" yaml:"message" mapstructure:"message"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *AuthenticatedExtendedCardNotConfiguredError) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["code"]; raw != nil && !ok { + return fmt.Errorf("field code in AuthenticatedExtendedCardNotConfiguredError: required") + } + type Plain AuthenticatedExtendedCardNotConfiguredError + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + if v, ok := raw["message"]; !ok || v == nil { + plain.Message = "Authenticated Extended Card is not configured" + } + *j = AuthenticatedExtendedCardNotConfiguredError(plain) + return nil +} + +// Defines configuration details for the OAuth 2.0 Authorization Code flow. +type AuthorizationCodeOAuthFlow struct { + // The authorization URL to be used for this flow. + // This MUST be a URL and use TLS. + AuthorizationUrl string `json:"authorizationUrl" yaml:"authorizationUrl" mapstructure:"authorizationUrl"` + + // The URL to be used for obtaining refresh tokens. + // This MUST be a URL and use TLS. + RefreshUrl *string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty" mapstructure:"refreshUrl,omitempty"` + + // The available scopes for the OAuth2 security scheme. A map between the scope + // name and a short description for it. + Scopes map[string]string `json:"scopes" yaml:"scopes" mapstructure:"scopes"` + + // The token URL to be used for this flow. + // This MUST be a URL and use TLS. + TokenUrl string `json:"tokenUrl" yaml:"tokenUrl" mapstructure:"tokenUrl"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *AuthorizationCodeOAuthFlow) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["authorizationUrl"]; raw != nil && !ok { + return fmt.Errorf("field authorizationUrl in AuthorizationCodeOAuthFlow: required") + } + if _, ok := raw["scopes"]; raw != nil && !ok { + return fmt.Errorf("field scopes in AuthorizationCodeOAuthFlow: required") + } + if _, ok := raw["tokenUrl"]; raw != nil && !ok { + return fmt.Errorf("field tokenUrl in AuthorizationCodeOAuthFlow: required") + } + type Plain AuthorizationCodeOAuthFlow + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = AuthorizationCodeOAuthFlow(plain) + return nil +} + +// Represents a JSON-RPC request for the `tasks/cancel` method. +type CancelTaskRequest struct { + // The identifier for this request. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The method name. Must be 'tasks/cancel'. + Method string `json:"method" yaml:"method" mapstructure:"method"` + + // The parameters identifying the task to cancel. + Params TaskIdParams `json:"params" yaml:"params" mapstructure:"params"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *CancelTaskRequest) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in CancelTaskRequest: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in CancelTaskRequest: required") + } + if _, ok := raw["method"]; raw != nil && !ok { + return fmt.Errorf("field method in CancelTaskRequest: required") + } + if _, ok := raw["params"]; raw != nil && !ok { + return fmt.Errorf("field params in CancelTaskRequest: required") + } + type Plain CancelTaskRequest + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = CancelTaskRequest(plain) + return nil +} + +// Represents a JSON-RPC response for the `tasks/cancel` method. +type CancelTaskResponse interface{} + +// Represents a successful JSON-RPC response for the `tasks/cancel` method. +type CancelTaskSuccessResponse struct { + // The identifier established by the client. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The result, containing the final state of the canceled Task object. + Result Task `json:"result" yaml:"result" mapstructure:"result"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *CancelTaskSuccessResponse) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in CancelTaskSuccessResponse: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in CancelTaskSuccessResponse: required") + } + if _, ok := raw["result"]; raw != nil && !ok { + return fmt.Errorf("field result in CancelTaskSuccessResponse: required") + } + type Plain CancelTaskSuccessResponse + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = CancelTaskSuccessResponse(plain) + return nil +} + +// Defines configuration details for the OAuth 2.0 Client Credentials flow. +type ClientCredentialsOAuthFlow struct { + // The URL to be used for obtaining refresh tokens. This MUST be a URL. + RefreshUrl *string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty" mapstructure:"refreshUrl,omitempty"` + + // The available scopes for the OAuth2 security scheme. A map between the scope + // name and a short description for it. + Scopes map[string]string `json:"scopes" yaml:"scopes" mapstructure:"scopes"` + + // The token URL to be used for this flow. This MUST be a URL. + TokenUrl string `json:"tokenUrl" yaml:"tokenUrl" mapstructure:"tokenUrl"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ClientCredentialsOAuthFlow) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["scopes"]; raw != nil && !ok { + return fmt.Errorf("field scopes in ClientCredentialsOAuthFlow: required") + } + if _, ok := raw["tokenUrl"]; raw != nil && !ok { + return fmt.Errorf("field tokenUrl in ClientCredentialsOAuthFlow: required") + } + type Plain ClientCredentialsOAuthFlow + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = ClientCredentialsOAuthFlow(plain) + return nil +} + +// An A2A-specific error indicating an incompatibility between the requested +// content types and the agent's capabilities. +type ContentTypeNotSupportedError struct { + // The error code for an unsupported content type. + Code int `json:"code" yaml:"code" mapstructure:"code"` + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` + + // The error message. + Message string `json:"message" yaml:"message" mapstructure:"message"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ContentTypeNotSupportedError) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["code"]; raw != nil && !ok { + return fmt.Errorf("field code in ContentTypeNotSupportedError: required") + } + type Plain ContentTypeNotSupportedError + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + if v, ok := raw["message"]; !ok || v == nil { + plain.Message = "Incompatible content types" + } + *j = ContentTypeNotSupportedError(plain) + return nil +} + +// Represents a structured data segment (e.g., JSON) within a message or artifact. +type DataPart struct { + // The structured data content. + Data map[string]interface{} `json:"data" yaml:"data" mapstructure:"data"` + + // The type of this part, used as a discriminator. Always 'data'. + Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` + + // Optional metadata associated with this part. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DataPart) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["data"]; raw != nil && !ok { + return fmt.Errorf("field data in DataPart: required") + } + if _, ok := raw["kind"]; raw != nil && !ok { + return fmt.Errorf("field kind in DataPart: required") + } + type Plain DataPart + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = DataPart(plain) + return nil +} + +// Defines parameters for deleting a specific push notification configuration for a +// task. +type DeleteTaskPushNotificationConfigParams struct { + // The unique identifier of the task. + Id string `json:"id" yaml:"id" mapstructure:"id"` + + // Optional metadata associated with the request. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` + + // The ID of the push notification configuration to delete. + PushNotificationConfigId string `json:"pushNotificationConfigId" yaml:"pushNotificationConfigId" mapstructure:"pushNotificationConfigId"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeleteTaskPushNotificationConfigParams) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in DeleteTaskPushNotificationConfigParams: required") + } + if _, ok := raw["pushNotificationConfigId"]; raw != nil && !ok { + return fmt.Errorf("field pushNotificationConfigId in DeleteTaskPushNotificationConfigParams: required") + } + type Plain DeleteTaskPushNotificationConfigParams + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = DeleteTaskPushNotificationConfigParams(plain) + return nil +} + +// Represents a JSON-RPC request for the `tasks/pushNotificationConfig/delete` +// method. +type DeleteTaskPushNotificationConfigRequest struct { + // The identifier for this request. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The method name. Must be 'tasks/pushNotificationConfig/delete'. + Method string `json:"method" yaml:"method" mapstructure:"method"` + + // The parameters identifying the push notification configuration to delete. + Params DeleteTaskPushNotificationConfigParams `json:"params" yaml:"params" mapstructure:"params"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeleteTaskPushNotificationConfigRequest) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in DeleteTaskPushNotificationConfigRequest: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in DeleteTaskPushNotificationConfigRequest: required") + } + if _, ok := raw["method"]; raw != nil && !ok { + return fmt.Errorf("field method in DeleteTaskPushNotificationConfigRequest: required") + } + if _, ok := raw["params"]; raw != nil && !ok { + return fmt.Errorf("field params in DeleteTaskPushNotificationConfigRequest: required") + } + type Plain DeleteTaskPushNotificationConfigRequest + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = DeleteTaskPushNotificationConfigRequest(plain) + return nil +} + +// Represents a JSON-RPC response for the `tasks/pushNotificationConfig/delete` +// method. +type DeleteTaskPushNotificationConfigResponse interface{} + +// Represents a successful JSON-RPC response for the +// `tasks/pushNotificationConfig/delete` method. +type DeleteTaskPushNotificationConfigSuccessResponse struct { + // The identifier established by the client. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The result is null on successful deletion. + Result interface{} `json:"result" yaml:"result" mapstructure:"result"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeleteTaskPushNotificationConfigSuccessResponse) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in DeleteTaskPushNotificationConfigSuccessResponse: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in DeleteTaskPushNotificationConfigSuccessResponse: required") + } + if _, ok := raw["result"]; raw != nil && !ok { + return fmt.Errorf("field result in DeleteTaskPushNotificationConfigSuccessResponse: required") + } + type Plain DeleteTaskPushNotificationConfigSuccessResponse + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + if plain.Result != nil { + return fmt.Errorf("field %s: must be null", "result") + } + *j = DeleteTaskPushNotificationConfigSuccessResponse(plain) + return nil +} + +// Defines base properties for a file. +type FileBase struct { + // The MIME type of the file (e.g., "application/pdf"). + MimeType *string `json:"mimeType,omitempty" yaml:"mimeType,omitempty" mapstructure:"mimeType,omitempty"` + + // An optional name for the file (e.g., "document.pdf"). + Name *string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty"` +} + +// Represents a file segment within a message or artifact. The file content can be +// provided either directly as bytes or as a URI. +type FilePart struct { + // The file content, represented as either a URI or as base64-encoded bytes. + File FilePartFile `json:"file" yaml:"file" mapstructure:"file"` + + // The type of this part, used as a discriminator. Always 'file'. + Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` + + // Optional metadata associated with this part. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` +} + +// Represents a file with its content provided directly as a base64-encoded string. +type FilePartFile struct { + // The base64-encoded content of the file. + Bytes string `json:"bytes" yaml:"bytes" mapstructure:"bytes"` + + // The MIME type of the file (e.g., "application/pdf"). + MimeType *string `json:"mimeType,omitempty" yaml:"mimeType,omitempty" mapstructure:"mimeType,omitempty"` + + // An optional name for the file (e.g., "document.pdf"). + Name *string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty"` + + // A URL pointing to the file's content. + Uri string `json:"uri" yaml:"uri" mapstructure:"uri"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *FilePartFile) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + var filePartFile_0 FilePartFile_0 + var filePartFile_1 FilePartFile_1 + var errs []error + if err := filePartFile_0.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := filePartFile_1.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if len(errs) == 2 { + return fmt.Errorf("all validators failed: %s", errors.Join(errs...)) + } + type Plain FilePartFile + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = FilePartFile(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *FilePart) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["file"]; raw != nil && !ok { + return fmt.Errorf("field file in FilePart: required") + } + if _, ok := raw["kind"]; raw != nil && !ok { + return fmt.Errorf("field kind in FilePart: required") + } + type Plain FilePart + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = FilePart(plain) + return nil +} + +// Represents a file with its content provided directly as a base64-encoded string. +type FileWithBytes struct { + // The base64-encoded content of the file. + Bytes string `json:"bytes" yaml:"bytes" mapstructure:"bytes"` + + // The MIME type of the file (e.g., "application/pdf"). + MimeType *string `json:"mimeType,omitempty" yaml:"mimeType,omitempty" mapstructure:"mimeType,omitempty"` + + // An optional name for the file (e.g., "document.pdf"). + Name *string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *FileWithBytes) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["bytes"]; raw != nil && !ok { + return fmt.Errorf("field bytes in FileWithBytes: required") + } + type Plain FileWithBytes + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = FileWithBytes(plain) + return nil +} + +// Represents a file with its content located at a specific URI. +type FileWithUri struct { + // The MIME type of the file (e.g., "application/pdf"). + MimeType *string `json:"mimeType,omitempty" yaml:"mimeType,omitempty" mapstructure:"mimeType,omitempty"` + + // An optional name for the file (e.g., "document.pdf"). + Name *string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty"` + + // A URL pointing to the file's content. + Uri string `json:"uri" yaml:"uri" mapstructure:"uri"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *FileWithUri) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["uri"]; raw != nil && !ok { + return fmt.Errorf("field uri in FileWithUri: required") + } + type Plain FileWithUri + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = FileWithUri(plain) + return nil +} + +// Represents a JSON-RPC request for the `agent/getAuthenticatedExtendedCard` +// method. +type GetAuthenticatedExtendedCardRequest struct { + // The identifier for this request. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The method name. Must be 'agent/getAuthenticatedExtendedCard'. + Method string `json:"method" yaml:"method" mapstructure:"method"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *GetAuthenticatedExtendedCardRequest) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in GetAuthenticatedExtendedCardRequest: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in GetAuthenticatedExtendedCardRequest: required") + } + if _, ok := raw["method"]; raw != nil && !ok { + return fmt.Errorf("field method in GetAuthenticatedExtendedCardRequest: required") + } + type Plain GetAuthenticatedExtendedCardRequest + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = GetAuthenticatedExtendedCardRequest(plain) + return nil +} + +// Represents a JSON-RPC response for the `agent/getAuthenticatedExtendedCard` +// method. +type GetAuthenticatedExtendedCardResponse interface{} + +// Represents a successful JSON-RPC response for the +// `agent/getAuthenticatedExtendedCard` method. +type GetAuthenticatedExtendedCardSuccessResponse struct { + // The identifier established by the client. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The result is an Agent Card object. + Result AgentCard `json:"result" yaml:"result" mapstructure:"result"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *GetAuthenticatedExtendedCardSuccessResponse) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in GetAuthenticatedExtendedCardSuccessResponse: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in GetAuthenticatedExtendedCardSuccessResponse: required") + } + if _, ok := raw["result"]; raw != nil && !ok { + return fmt.Errorf("field result in GetAuthenticatedExtendedCardSuccessResponse: required") + } + type Plain GetAuthenticatedExtendedCardSuccessResponse + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = GetAuthenticatedExtendedCardSuccessResponse(plain) + return nil +} + +// Defines parameters for fetching a specific push notification configuration for a +// task. +type GetTaskPushNotificationConfigParams struct { + // The unique identifier of the task. + Id string `json:"id" yaml:"id" mapstructure:"id"` + + // Optional metadata associated with the request. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` + + // The ID of the push notification configuration to retrieve. + PushNotificationConfigId *string `json:"pushNotificationConfigId,omitempty" yaml:"pushNotificationConfigId,omitempty" mapstructure:"pushNotificationConfigId,omitempty"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *GetTaskPushNotificationConfigParams) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in GetTaskPushNotificationConfigParams: required") + } + type Plain GetTaskPushNotificationConfigParams + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = GetTaskPushNotificationConfigParams(plain) + return nil +} + +// Represents a JSON-RPC request for the `tasks/pushNotificationConfig/get` method. +type GetTaskPushNotificationConfigRequest struct { + // The identifier for this request. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The method name. Must be 'tasks/pushNotificationConfig/get'. + Method string `json:"method" yaml:"method" mapstructure:"method"` + + // The parameters for getting a push notification configuration. + Params GetTaskPushNotificationConfigRequestParams `json:"params" yaml:"params" mapstructure:"params"` +} + +// Defines parameters containing a task ID, used for simple task operations. +type GetTaskPushNotificationConfigRequestParams struct { + // The unique identifier of the task. + Id string `json:"id" yaml:"id" mapstructure:"id"` + + // Optional metadata associated with the request. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` + + // The ID of the push notification configuration to retrieve. + PushNotificationConfigId *string `json:"pushNotificationConfigId,omitempty" yaml:"pushNotificationConfigId,omitempty" mapstructure:"pushNotificationConfigId,omitempty"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *GetTaskPushNotificationConfigRequestParams) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + var getTaskPushNotificationConfigRequestParams_0 GetTaskPushNotificationConfigRequestParams_0 + var getTaskPushNotificationConfigRequestParams_1 GetTaskPushNotificationConfigRequestParams_1 + var errs []error + if err := getTaskPushNotificationConfigRequestParams_0.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := getTaskPushNotificationConfigRequestParams_1.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if len(errs) == 2 { + return fmt.Errorf("all validators failed: %s", errors.Join(errs...)) + } + type Plain GetTaskPushNotificationConfigRequestParams + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = GetTaskPushNotificationConfigRequestParams(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *GetTaskPushNotificationConfigRequest) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in GetTaskPushNotificationConfigRequest: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in GetTaskPushNotificationConfigRequest: required") + } + if _, ok := raw["method"]; raw != nil && !ok { + return fmt.Errorf("field method in GetTaskPushNotificationConfigRequest: required") + } + if _, ok := raw["params"]; raw != nil && !ok { + return fmt.Errorf("field params in GetTaskPushNotificationConfigRequest: required") + } + type Plain GetTaskPushNotificationConfigRequest + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = GetTaskPushNotificationConfigRequest(plain) + return nil +} + +// Represents a JSON-RPC response for the `tasks/pushNotificationConfig/get` +// method. +type GetTaskPushNotificationConfigResponse interface{} + +// Represents a successful JSON-RPC response for the +// `tasks/pushNotificationConfig/get` method. +type GetTaskPushNotificationConfigSuccessResponse struct { + // The identifier established by the client. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The result, containing the requested push notification configuration. + Result TaskPushNotificationConfig `json:"result" yaml:"result" mapstructure:"result"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *GetTaskPushNotificationConfigSuccessResponse) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in GetTaskPushNotificationConfigSuccessResponse: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in GetTaskPushNotificationConfigSuccessResponse: required") + } + if _, ok := raw["result"]; raw != nil && !ok { + return fmt.Errorf("field result in GetTaskPushNotificationConfigSuccessResponse: required") + } + type Plain GetTaskPushNotificationConfigSuccessResponse + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = GetTaskPushNotificationConfigSuccessResponse(plain) + return nil +} + +// Represents a JSON-RPC request for the `tasks/get` method. +type GetTaskRequest struct { + // The identifier for this request. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The method name. Must be 'tasks/get'. + Method string `json:"method" yaml:"method" mapstructure:"method"` + + // The parameters for querying a task. + Params TaskQueryParams `json:"params" yaml:"params" mapstructure:"params"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *GetTaskRequest) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in GetTaskRequest: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in GetTaskRequest: required") + } + if _, ok := raw["method"]; raw != nil && !ok { + return fmt.Errorf("field method in GetTaskRequest: required") + } + if _, ok := raw["params"]; raw != nil && !ok { + return fmt.Errorf("field params in GetTaskRequest: required") + } + type Plain GetTaskRequest + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = GetTaskRequest(plain) + return nil +} + +// Represents a JSON-RPC response for the `tasks/get` method. +type GetTaskResponse interface{} + +// Represents a successful JSON-RPC response for the `tasks/get` method. +type GetTaskSuccessResponse struct { + // The identifier established by the client. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The result, containing the requested Task object. + Result Task `json:"result" yaml:"result" mapstructure:"result"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *GetTaskSuccessResponse) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in GetTaskSuccessResponse: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in GetTaskSuccessResponse: required") + } + if _, ok := raw["result"]; raw != nil && !ok { + return fmt.Errorf("field result in GetTaskSuccessResponse: required") + } + type Plain GetTaskSuccessResponse + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = GetTaskSuccessResponse(plain) + return nil +} + +// Defines a security scheme using HTTP authentication. +type HTTPAuthSecurityScheme struct { + // A hint to the client to identify how the bearer token is formatted (e.g., + // "JWT"). + // This is primarily for documentation purposes. + BearerFormat *string `json:"bearerFormat,omitempty" yaml:"bearerFormat,omitempty" mapstructure:"bearerFormat,omitempty"` + + // An optional description for the security scheme. + Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` + + // The name of the HTTP Authentication scheme to be used in the Authorization + // header, + // as defined in RFC7235 (e.g., "Bearer"). + // This value should be registered in the IANA Authentication Scheme registry. + Scheme string `json:"scheme" yaml:"scheme" mapstructure:"scheme"` + + // The type of the security scheme. Must be 'http'. + Type string `json:"type" yaml:"type" mapstructure:"type"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *HTTPAuthSecurityScheme) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["scheme"]; raw != nil && !ok { + return fmt.Errorf("field scheme in HTTPAuthSecurityScheme: required") + } + if _, ok := raw["type"]; raw != nil && !ok { + return fmt.Errorf("field type in HTTPAuthSecurityScheme: required") + } + type Plain HTTPAuthSecurityScheme + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = HTTPAuthSecurityScheme(plain) + return nil +} + +// Defines configuration details for the OAuth 2.0 Implicit flow. +type ImplicitOAuthFlow struct { + // The authorization URL to be used for this flow. This MUST be a URL. + AuthorizationUrl string `json:"authorizationUrl" yaml:"authorizationUrl" mapstructure:"authorizationUrl"` + + // The URL to be used for obtaining refresh tokens. This MUST be a URL. + RefreshUrl *string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty" mapstructure:"refreshUrl,omitempty"` + + // The available scopes for the OAuth2 security scheme. A map between the scope + // name and a short description for it. + Scopes map[string]string `json:"scopes" yaml:"scopes" mapstructure:"scopes"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ImplicitOAuthFlow) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["authorizationUrl"]; raw != nil && !ok { + return fmt.Errorf("field authorizationUrl in ImplicitOAuthFlow: required") + } + if _, ok := raw["scopes"]; raw != nil && !ok { + return fmt.Errorf("field scopes in ImplicitOAuthFlow: required") + } + type Plain ImplicitOAuthFlow + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = ImplicitOAuthFlow(plain) + return nil +} + +// An error indicating an internal error on the server. +type InternalError struct { + // The error code for an internal server error. + Code int `json:"code" yaml:"code" mapstructure:"code"` + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` + + // The error message. + Message string `json:"message" yaml:"message" mapstructure:"message"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *InternalError) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["code"]; raw != nil && !ok { + return fmt.Errorf("field code in InternalError: required") + } + type Plain InternalError + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + if v, ok := raw["message"]; !ok || v == nil { + plain.Message = "Internal error" + } + *j = InternalError(plain) + return nil +} + +// An A2A-specific error indicating that the agent returned a response that +// does not conform to the specification for the current method. +type InvalidAgentResponseError struct { + // The error code for an invalid agent response. + Code int `json:"code" yaml:"code" mapstructure:"code"` + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` + + // The error message. + Message string `json:"message" yaml:"message" mapstructure:"message"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *InvalidAgentResponseError) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["code"]; raw != nil && !ok { + return fmt.Errorf("field code in InvalidAgentResponseError: required") + } + type Plain InvalidAgentResponseError + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + if v, ok := raw["message"]; !ok || v == nil { + plain.Message = "Invalid agent response" + } + *j = InvalidAgentResponseError(plain) + return nil +} + +// An error indicating that the method parameters are invalid. +type InvalidParamsError struct { + // The error code for an invalid parameters error. + Code int `json:"code" yaml:"code" mapstructure:"code"` + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` + + // The error message. + Message string `json:"message" yaml:"message" mapstructure:"message"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *InvalidParamsError) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["code"]; raw != nil && !ok { + return fmt.Errorf("field code in InvalidParamsError: required") + } + type Plain InvalidParamsError + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + if v, ok := raw["message"]; !ok || v == nil { + plain.Message = "Invalid parameters" + } + *j = InvalidParamsError(plain) + return nil +} + +// An error indicating that the JSON sent is not a valid Request object. +type InvalidRequestError struct { + // The error code for an invalid request. + Code int `json:"code" yaml:"code" mapstructure:"code"` + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` + + // The error message. + Message string `json:"message" yaml:"message" mapstructure:"message"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *InvalidRequestError) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["code"]; raw != nil && !ok { + return fmt.Errorf("field code in InvalidRequestError: required") + } + type Plain InvalidRequestError + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + if v, ok := raw["message"]; !ok || v == nil { + plain.Message = "Request payload validation error" + } + *j = InvalidRequestError(plain) + return nil +} + +// An error indicating that the server received invalid JSON. +type JSONParseError struct { + // The error code for a JSON parse error. + Code int `json:"code" yaml:"code" mapstructure:"code"` + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` + + // The error message. + Message string `json:"message" yaml:"message" mapstructure:"message"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *JSONParseError) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["code"]; raw != nil && !ok { + return fmt.Errorf("field code in JSONParseError: required") + } + type Plain JSONParseError + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + if v, ok := raw["message"]; !ok || v == nil { + plain.Message = "Invalid JSON payload" + } + *j = JSONParseError(plain) + return nil +} + +// Represents a JSON-RPC 2.0 Error object, included in an error response. +type JSONRPCError struct { + // A number that indicates the error type that occurred. + Code int `json:"code" yaml:"code" mapstructure:"code"` + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` + + // A string providing a short description of the error. + Message string `json:"message" yaml:"message" mapstructure:"message"` +} + +// Represents a JSON-RPC 2.0 Error Response object. +type JSONRPCErrorResponse struct { + // An object describing the error that occurred. + Error JSONRPCErrorResponseError `json:"error" yaml:"error" mapstructure:"error"` + + // The identifier established by the client. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` +} + +// Represents a JSON-RPC 2.0 Error object, included in an error response. +type JSONRPCErrorResponseError struct { + // A number that indicates the error type that occurred. + Code int `json:"code" yaml:"code" mapstructure:"code"` + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` + + // A string providing a short description of the error. + Message string `json:"message" yaml:"message" mapstructure:"message"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *JSONRPCErrorResponseError) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + var jSONRPCErrorResponseError_0 JSONRPCErrorResponseError_0 + var jSONRPCErrorResponseError_1 JSONRPCErrorResponseError_1 + var jSONRPCErrorResponseError_2 JSONRPCErrorResponseError_2 + var jSONRPCErrorResponseError_3 JSONRPCErrorResponseError_3 + var jSONRPCErrorResponseError_4 JSONRPCErrorResponseError_4 + var jSONRPCErrorResponseError_5 JSONRPCErrorResponseError_5 + var jSONRPCErrorResponseError_6 JSONRPCErrorResponseError_6 + var jSONRPCErrorResponseError_7 JSONRPCErrorResponseError_7 + var jSONRPCErrorResponseError_8 JSONRPCErrorResponseError_8 + var jSONRPCErrorResponseError_9 JSONRPCErrorResponseError_9 + var jSONRPCErrorResponseError_10 JSONRPCErrorResponseError_10 + var jSONRPCErrorResponseError_11 JSONRPCErrorResponseError_11 + var jSONRPCErrorResponseError_12 JSONRPCErrorResponseError_12 + var errs []error + if err := jSONRPCErrorResponseError_0.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := jSONRPCErrorResponseError_1.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := jSONRPCErrorResponseError_2.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := jSONRPCErrorResponseError_3.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := jSONRPCErrorResponseError_4.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := jSONRPCErrorResponseError_5.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := jSONRPCErrorResponseError_6.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := jSONRPCErrorResponseError_7.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := jSONRPCErrorResponseError_8.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := jSONRPCErrorResponseError_9.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := jSONRPCErrorResponseError_10.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := jSONRPCErrorResponseError_11.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := jSONRPCErrorResponseError_12.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if len(errs) == 13 { + return fmt.Errorf("all validators failed: %s", errors.Join(errs...)) + } + type Plain JSONRPCErrorResponseError + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = JSONRPCErrorResponseError(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *JSONRPCErrorResponse) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["error"]; raw != nil && !ok { + return fmt.Errorf("field error in JSONRPCErrorResponse: required") + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in JSONRPCErrorResponse: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in JSONRPCErrorResponse: required") + } + type Plain JSONRPCErrorResponse + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = JSONRPCErrorResponse(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *JSONRPCError) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["code"]; raw != nil && !ok { + return fmt.Errorf("field code in JSONRPCError: required") + } + if _, ok := raw["message"]; raw != nil && !ok { + return fmt.Errorf("field message in JSONRPCError: required") + } + type Plain JSONRPCError + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = JSONRPCError(plain) + return nil +} + +// Defines the base structure for any JSON-RPC 2.0 request, response, or +// notification. +type JSONRPCMessage struct { + // A unique identifier established by the client. It must be a String, a Number, + // or null. + // The server must reply with the same value in the response. This property is + // omitted for notifications. + Id interface{} `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id,omitempty"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *JSONRPCMessage) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in JSONRPCMessage: required") + } + type Plain JSONRPCMessage + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = JSONRPCMessage(plain) + return nil +} + +// Represents a JSON-RPC 2.0 Request object. +type JSONRPCRequest struct { + // A unique identifier established by the client. It must be a String, a Number, + // or null. + // The server must reply with the same value in the response. This property is + // omitted for notifications. + Id interface{} `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id,omitempty"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // A string containing the name of the method to be invoked. + Method string `json:"method" yaml:"method" mapstructure:"method"` + + // A structured value holding the parameter values to be used during the method + // invocation. + Params map[string]interface{} `json:"params,omitempty" yaml:"params,omitempty" mapstructure:"params,omitempty"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *JSONRPCRequest) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in JSONRPCRequest: required") + } + if _, ok := raw["method"]; raw != nil && !ok { + return fmt.Errorf("field method in JSONRPCRequest: required") + } + type Plain JSONRPCRequest + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = JSONRPCRequest(plain) + return nil +} + +// A discriminated union representing all possible JSON-RPC 2.0 responses +// for the A2A specification methods. +type JSONRPCResponse interface{} + +// Represents a successful JSON-RPC 2.0 Response object. +type JSONRPCSuccessResponse struct { + // The identifier established by the client. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The value of this member is determined by the method invoked on the Server. + Result interface{} `json:"result" yaml:"result" mapstructure:"result"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *JSONRPCSuccessResponse) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in JSONRPCSuccessResponse: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in JSONRPCSuccessResponse: required") + } + if _, ok := raw["result"]; raw != nil && !ok { + return fmt.Errorf("field result in JSONRPCSuccessResponse: required") + } + type Plain JSONRPCSuccessResponse + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = JSONRPCSuccessResponse(plain) + return nil +} + +// Defines parameters for listing all push notification configurations associated +// with a task. +type ListTaskPushNotificationConfigParams struct { + // The unique identifier of the task. + Id string `json:"id" yaml:"id" mapstructure:"id"` + + // Optional metadata associated with the request. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ListTaskPushNotificationConfigParams) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in ListTaskPushNotificationConfigParams: required") + } + type Plain ListTaskPushNotificationConfigParams + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = ListTaskPushNotificationConfigParams(plain) + return nil +} + +// Represents a JSON-RPC request for the `tasks/pushNotificationConfig/list` +// method. +type ListTaskPushNotificationConfigRequest struct { + // The identifier for this request. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The method name. Must be 'tasks/pushNotificationConfig/list'. + Method string `json:"method" yaml:"method" mapstructure:"method"` + + // The parameters identifying the task whose configurations are to be listed. + Params ListTaskPushNotificationConfigParams `json:"params" yaml:"params" mapstructure:"params"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ListTaskPushNotificationConfigRequest) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in ListTaskPushNotificationConfigRequest: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in ListTaskPushNotificationConfigRequest: required") + } + if _, ok := raw["method"]; raw != nil && !ok { + return fmt.Errorf("field method in ListTaskPushNotificationConfigRequest: required") + } + if _, ok := raw["params"]; raw != nil && !ok { + return fmt.Errorf("field params in ListTaskPushNotificationConfigRequest: required") + } + type Plain ListTaskPushNotificationConfigRequest + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = ListTaskPushNotificationConfigRequest(plain) + return nil +} + +// Represents a JSON-RPC response for the `tasks/pushNotificationConfig/list` +// method. +type ListTaskPushNotificationConfigResponse interface{} + +// Represents a successful JSON-RPC response for the +// `tasks/pushNotificationConfig/list` method. +type ListTaskPushNotificationConfigSuccessResponse struct { + // The identifier established by the client. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The result, containing an array of all push notification configurations for the + // task. + Result []TaskPushNotificationConfig `json:"result" yaml:"result" mapstructure:"result"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ListTaskPushNotificationConfigSuccessResponse) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in ListTaskPushNotificationConfigSuccessResponse: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in ListTaskPushNotificationConfigSuccessResponse: required") + } + if _, ok := raw["result"]; raw != nil && !ok { + return fmt.Errorf("field result in ListTaskPushNotificationConfigSuccessResponse: required") + } + type Plain ListTaskPushNotificationConfigSuccessResponse + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = ListTaskPushNotificationConfigSuccessResponse(plain) + return nil +} + +// Represents a single message in the conversation between a user and an agent. +type Message struct { + // The context identifier for this message, used to group related interactions. + ContextId *string `json:"contextId,omitempty" yaml:"contextId,omitempty" mapstructure:"contextId,omitempty"` + + // The URIs of extensions that are relevant to this message. + Extensions []string `json:"extensions,omitempty" yaml:"extensions,omitempty" mapstructure:"extensions,omitempty"` + + // The type of this object, used as a discriminator. Always 'message' for a + // Message. + Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` + + // A unique identifier for the message, typically a UUID, generated by the sender. + MessageId string `json:"messageId" yaml:"messageId" mapstructure:"messageId"` + + // Optional metadata for extensions. The key is an extension-specific identifier. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` + + // An array of content parts that form the message body. A message can be + // composed of multiple parts of different types (e.g., text and files). + Parts []MessagePartsElem `json:"parts" yaml:"parts" mapstructure:"parts"` + + // A list of other task IDs that this message references for additional context. + ReferenceTaskIds []string `json:"referenceTaskIds,omitempty" yaml:"referenceTaskIds,omitempty" mapstructure:"referenceTaskIds,omitempty"` + + // Identifies the sender of the message. `user` for the client, `agent` for the + // service. + Role MessageRole `json:"role" yaml:"role" mapstructure:"role"` + + // The identifier of the task this message is part of. Can be omitted for the + // first message of a new task. + TaskId *string `json:"taskId,omitempty" yaml:"taskId,omitempty" mapstructure:"taskId,omitempty"` +} + +type MessagePartsElem interface{} + +type MessageRole string + +const MessageRoleAgent MessageRole = "agent" +const MessageRoleUser MessageRole = "user" + +var enumValues_MessageRole = []interface{}{ + "agent", + "user", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *MessageRole) UnmarshalJSON(value []byte) error { + var v string + if err := json.Unmarshal(value, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_MessageRole { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_MessageRole, v) + } + *j = MessageRole(v) + return nil +} + +// Defines configuration options for a `message/send` or `message/stream` request. +type MessageSendConfiguration struct { + // A list of output MIME types the client is prepared to accept in the response. + AcceptedOutputModes []string `json:"acceptedOutputModes,omitempty" yaml:"acceptedOutputModes,omitempty" mapstructure:"acceptedOutputModes,omitempty"` + + // If true, the client will wait for the task to complete. The server may reject + // this if the task is long-running. + Blocking *bool `json:"blocking,omitempty" yaml:"blocking,omitempty" mapstructure:"blocking,omitempty"` + + // The number of most recent messages from the task's history to retrieve in the + // response. + HistoryLength *int `json:"historyLength,omitempty" yaml:"historyLength,omitempty" mapstructure:"historyLength,omitempty"` + + // Configuration for the agent to send push notifications for updates after the + // initial response. + PushNotificationConfig *PushNotificationConfig `json:"pushNotificationConfig,omitempty" yaml:"pushNotificationConfig,omitempty" mapstructure:"pushNotificationConfig,omitempty"` +} + +// Defines the parameters for a request to send a message to an agent. This can be +// used +// to create a new task, continue an existing one, or restart a task. +type MessageSendParams struct { + // Optional configuration for the send request. + Configuration *MessageSendConfiguration `json:"configuration,omitempty" yaml:"configuration,omitempty" mapstructure:"configuration,omitempty"` + + // The message object being sent to the agent. + Message Message `json:"message" yaml:"message" mapstructure:"message"` + + // Optional metadata for extensions. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *MessageSendParams) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["message"]; raw != nil && !ok { + return fmt.Errorf("field message in MessageSendParams: required") + } + type Plain MessageSendParams + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = MessageSendParams(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *Message) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["kind"]; raw != nil && !ok { + return fmt.Errorf("field kind in Message: required") + } + if _, ok := raw["messageId"]; raw != nil && !ok { + return fmt.Errorf("field messageId in Message: required") + } + if _, ok := raw["parts"]; raw != nil && !ok { + return fmt.Errorf("field parts in Message: required") + } + if _, ok := raw["role"]; raw != nil && !ok { + return fmt.Errorf("field role in Message: required") + } + type Plain Message + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = Message(plain) + return nil +} + +// An error indicating that the requested method does not exist or is not +// available. +type MethodNotFoundError struct { + // The error code for a method not found error. + Code int `json:"code" yaml:"code" mapstructure:"code"` + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` + + // The error message. + Message string `json:"message" yaml:"message" mapstructure:"message"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *MethodNotFoundError) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["code"]; raw != nil && !ok { + return fmt.Errorf("field code in MethodNotFoundError: required") + } + type Plain MethodNotFoundError + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + if v, ok := raw["message"]; !ok || v == nil { + plain.Message = "Method not found" + } + *j = MethodNotFoundError(plain) + return nil +} + +// Defines a security scheme using mTLS authentication. +type MutualTLSSecurityScheme struct { + // An optional description for the security scheme. + Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` + + // The type of the security scheme. Must be 'mutualTLS'. + Type string `json:"type" yaml:"type" mapstructure:"type"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *MutualTLSSecurityScheme) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["type"]; raw != nil && !ok { + return fmt.Errorf("field type in MutualTLSSecurityScheme: required") + } + type Plain MutualTLSSecurityScheme + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = MutualTLSSecurityScheme(plain) + return nil +} + +// Defines a security scheme using OAuth 2.0. +type OAuth2SecurityScheme struct { + // An optional description for the security scheme. + Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` + + // An object containing configuration information for the supported OAuth 2.0 + // flows. + Flows OAuthFlows `json:"flows" yaml:"flows" mapstructure:"flows"` + + // URL to the oauth2 authorization server metadata + // [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414). TLS is required. + Oauth2MetadataUrl *string `json:"oauth2MetadataUrl,omitempty" yaml:"oauth2MetadataUrl,omitempty" mapstructure:"oauth2MetadataUrl,omitempty"` + + // The type of the security scheme. Must be 'oauth2'. + Type string `json:"type" yaml:"type" mapstructure:"type"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *OAuth2SecurityScheme) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["flows"]; raw != nil && !ok { + return fmt.Errorf("field flows in OAuth2SecurityScheme: required") + } + if _, ok := raw["type"]; raw != nil && !ok { + return fmt.Errorf("field type in OAuth2SecurityScheme: required") + } + type Plain OAuth2SecurityScheme + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = OAuth2SecurityScheme(plain) + return nil +} + +// Defines the configuration for the supported OAuth 2.0 flows. +type OAuthFlows struct { + // Configuration for the OAuth Authorization Code flow. Previously called + // accessCode in OpenAPI 2.0. + AuthorizationCode *AuthorizationCodeOAuthFlow `json:"authorizationCode,omitempty" yaml:"authorizationCode,omitempty" mapstructure:"authorizationCode,omitempty"` + + // Configuration for the OAuth Client Credentials flow. Previously called + // application in OpenAPI 2.0. + ClientCredentials *ClientCredentialsOAuthFlow `json:"clientCredentials,omitempty" yaml:"clientCredentials,omitempty" mapstructure:"clientCredentials,omitempty"` + + // Configuration for the OAuth Implicit flow. + Implicit *ImplicitOAuthFlow `json:"implicit,omitempty" yaml:"implicit,omitempty" mapstructure:"implicit,omitempty"` + + // Configuration for the OAuth Resource Owner Password flow. + Password *PasswordOAuthFlow `json:"password,omitempty" yaml:"password,omitempty" mapstructure:"password,omitempty"` +} + +// Defines a security scheme using OpenID Connect. +type OpenIdConnectSecurityScheme struct { + // An optional description for the security scheme. + Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` + + // The OpenID Connect Discovery URL for the OIDC provider's metadata. + OpenIdConnectUrl string `json:"openIdConnectUrl" yaml:"openIdConnectUrl" mapstructure:"openIdConnectUrl"` + + // The type of the security scheme. Must be 'openIdConnect'. + Type string `json:"type" yaml:"type" mapstructure:"type"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *OpenIdConnectSecurityScheme) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["openIdConnectUrl"]; raw != nil && !ok { + return fmt.Errorf("field openIdConnectUrl in OpenIdConnectSecurityScheme: required") + } + if _, ok := raw["type"]; raw != nil && !ok { + return fmt.Errorf("field type in OpenIdConnectSecurityScheme: required") + } + type Plain OpenIdConnectSecurityScheme + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = OpenIdConnectSecurityScheme(plain) + return nil +} + +// A discriminated union representing a part of a message or artifact, which can +// be text, a file, or structured data. +type Part interface{} + +// Defines base properties common to all message or artifact parts. +type PartBase struct { + // Optional metadata associated with this part. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` +} + +// Defines configuration details for the OAuth 2.0 Resource Owner Password flow. +type PasswordOAuthFlow struct { + // The URL to be used for obtaining refresh tokens. This MUST be a URL. + RefreshUrl *string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty" mapstructure:"refreshUrl,omitempty"` + + // The available scopes for the OAuth2 security scheme. A map between the scope + // name and a short description for it. + Scopes map[string]string `json:"scopes" yaml:"scopes" mapstructure:"scopes"` + + // The token URL to be used for this flow. This MUST be a URL. + TokenUrl string `json:"tokenUrl" yaml:"tokenUrl" mapstructure:"tokenUrl"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *PasswordOAuthFlow) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["scopes"]; raw != nil && !ok { + return fmt.Errorf("field scopes in PasswordOAuthFlow: required") + } + if _, ok := raw["tokenUrl"]; raw != nil && !ok { + return fmt.Errorf("field tokenUrl in PasswordOAuthFlow: required") + } + type Plain PasswordOAuthFlow + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = PasswordOAuthFlow(plain) + return nil +} + +// Defines authentication details for a push notification endpoint. +type PushNotificationAuthenticationInfo struct { + // Optional credentials required by the push notification endpoint. + Credentials *string `json:"credentials,omitempty" yaml:"credentials,omitempty" mapstructure:"credentials,omitempty"` + + // A list of supported authentication schemes (e.g., 'Basic', 'Bearer'). + Schemes []string `json:"schemes" yaml:"schemes" mapstructure:"schemes"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *PushNotificationAuthenticationInfo) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["schemes"]; raw != nil && !ok { + return fmt.Errorf("field schemes in PushNotificationAuthenticationInfo: required") + } + type Plain PushNotificationAuthenticationInfo + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = PushNotificationAuthenticationInfo(plain) + return nil +} + +// Defines the configuration for setting up push notifications for task updates. +type PushNotificationConfig struct { + // Optional authentication details for the agent to use when calling the + // notification URL. + Authentication *PushNotificationAuthenticationInfo `json:"authentication,omitempty" yaml:"authentication,omitempty" mapstructure:"authentication,omitempty"` + + // A unique ID for the push notification configuration, set by the client + // to support multiple notification callbacks. + Id *string `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id,omitempty"` + + // A unique token for this task or session to validate incoming push + // notifications. + Token *string `json:"token,omitempty" yaml:"token,omitempty" mapstructure:"token,omitempty"` + + // The callback URL where the agent should send push notifications. + Url string `json:"url" yaml:"url" mapstructure:"url"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *PushNotificationConfig) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["url"]; raw != nil && !ok { + return fmt.Errorf("field url in PushNotificationConfig: required") + } + type Plain PushNotificationConfig + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = PushNotificationConfig(plain) + return nil +} + +// An A2A-specific error indicating that the agent does not support push +// notifications. +type PushNotificationNotSupportedError struct { + // The error code for when push notifications are not supported. + Code int `json:"code" yaml:"code" mapstructure:"code"` + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` + + // The error message. + Message string `json:"message" yaml:"message" mapstructure:"message"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *PushNotificationNotSupportedError) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["code"]; raw != nil && !ok { + return fmt.Errorf("field code in PushNotificationNotSupportedError: required") + } + type Plain PushNotificationNotSupportedError + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + if v, ok := raw["message"]; !ok || v == nil { + plain.Message = "Push Notification is not supported" + } + *j = PushNotificationNotSupportedError(plain) + return nil +} + +// Defines a security scheme that can be used to secure an agent's endpoints. +// This is a discriminated union type based on the OpenAPI 3.0 Security Scheme +// Object. +type SecurityScheme interface{} + +// Defines base properties shared by all security scheme objects. +type SecuritySchemeBase struct { + // An optional description for the security scheme. + Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` +} + +// Represents a JSON-RPC request for the `message/send` method. +type SendMessageRequest struct { + // The identifier for this request. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The method name. Must be 'message/send'. + Method string `json:"method" yaml:"method" mapstructure:"method"` + + // The parameters for sending a message. + Params MessageSendParams `json:"params" yaml:"params" mapstructure:"params"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *SendMessageRequest) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in SendMessageRequest: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in SendMessageRequest: required") + } + if _, ok := raw["method"]; raw != nil && !ok { + return fmt.Errorf("field method in SendMessageRequest: required") + } + if _, ok := raw["params"]; raw != nil && !ok { + return fmt.Errorf("field params in SendMessageRequest: required") + } + type Plain SendMessageRequest + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = SendMessageRequest(plain) + return nil +} + +// Represents a JSON-RPC response for the `message/send` method. +type SendMessageResponse interface{} + +// Represents a successful JSON-RPC response for the `message/send` method. +type SendMessageSuccessResponse struct { + // The identifier established by the client. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The result, which can be a direct reply Message or the initial Task object. + Result SendMessageSuccessResponseResult `json:"result" yaml:"result" mapstructure:"result"` +} + +// Represents a single, stateful operation or conversation between a client and an +// agent. +type SendMessageSuccessResponseResult struct { + // A collection of artifacts generated by the agent during the execution of the + // task. + Artifacts []Artifact `json:"artifacts,omitempty" yaml:"artifacts,omitempty" mapstructure:"artifacts,omitempty"` + + // A server-generated identifier for maintaining context across multiple related + // tasks or interactions. + ContextId string `json:"contextId" yaml:"contextId" mapstructure:"contextId"` + + // The URIs of extensions that are relevant to this message. + Extensions []string `json:"extensions,omitempty" yaml:"extensions,omitempty" mapstructure:"extensions,omitempty"` + + // An array of messages exchanged during the task, representing the conversation + // history. + History []Message `json:"history,omitempty" yaml:"history,omitempty" mapstructure:"history,omitempty"` + + // A unique identifier for the task, generated by the server for a new task. + Id string `json:"id" yaml:"id" mapstructure:"id"` + + // The type of this object, used as a discriminator. Always 'task' for a Task. + Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` + + // A unique identifier for the message, typically a UUID, generated by the sender. + MessageId string `json:"messageId" yaml:"messageId" mapstructure:"messageId"` + + // Optional metadata for extensions. The key is an extension-specific identifier. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` + + // An array of content parts that form the message body. A message can be + // composed of multiple parts of different types (e.g., text and files). + Parts []MessagePartsElem `json:"parts" yaml:"parts" mapstructure:"parts"` + + // A list of other task IDs that this message references for additional context. + ReferenceTaskIds []string `json:"referenceTaskIds,omitempty" yaml:"referenceTaskIds,omitempty" mapstructure:"referenceTaskIds,omitempty"` + + // Identifies the sender of the message. `user` for the client, `agent` for the + // service. + Role MessageRole `json:"role" yaml:"role" mapstructure:"role"` + + // The current status of the task, including its state and a descriptive message. + Status TaskStatus `json:"status" yaml:"status" mapstructure:"status"` + + // The identifier of the task this message is part of. Can be omitted for the + // first message of a new task. + TaskId *string `json:"taskId,omitempty" yaml:"taskId,omitempty" mapstructure:"taskId,omitempty"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *SendMessageSuccessResponseResult) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + var sendMessageSuccessResponseResult_0 SendMessageSuccessResponseResult_0 + var sendMessageSuccessResponseResult_1 SendMessageSuccessResponseResult_1 + var errs []error + if err := sendMessageSuccessResponseResult_0.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := sendMessageSuccessResponseResult_1.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if len(errs) == 2 { + return fmt.Errorf("all validators failed: %s", errors.Join(errs...)) + } + type Plain SendMessageSuccessResponseResult + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = SendMessageSuccessResponseResult(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *SendMessageSuccessResponse) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in SendMessageSuccessResponse: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in SendMessageSuccessResponse: required") + } + if _, ok := raw["result"]; raw != nil && !ok { + return fmt.Errorf("field result in SendMessageSuccessResponse: required") + } + type Plain SendMessageSuccessResponse + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = SendMessageSuccessResponse(plain) + return nil +} + +// Represents a JSON-RPC request for the `message/stream` method. +type SendStreamingMessageRequest struct { + // The identifier for this request. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The method name. Must be 'message/stream'. + Method string `json:"method" yaml:"method" mapstructure:"method"` + + // The parameters for sending a message. + Params MessageSendParams `json:"params" yaml:"params" mapstructure:"params"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *SendStreamingMessageRequest) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in SendStreamingMessageRequest: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in SendStreamingMessageRequest: required") + } + if _, ok := raw["method"]; raw != nil && !ok { + return fmt.Errorf("field method in SendStreamingMessageRequest: required") + } + if _, ok := raw["params"]; raw != nil && !ok { + return fmt.Errorf("field params in SendStreamingMessageRequest: required") + } + type Plain SendStreamingMessageRequest + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = SendStreamingMessageRequest(plain) + return nil +} + +// Represents a JSON-RPC response for the `message/stream` method. +type SendStreamingMessageResponse interface{} + +// Represents a successful JSON-RPC response for the `message/stream` method. +// The server may send multiple response objects for a single request. +type SendStreamingMessageSuccessResponse struct { + // The identifier established by the client. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The result, which can be a Message, Task, or a streaming update event. + Result SendStreamingMessageSuccessResponseResult `json:"result" yaml:"result" mapstructure:"result"` +} + +// Represents a single, stateful operation or conversation between a client and an +// agent. +type SendStreamingMessageSuccessResponseResult struct { + // If true, the content of this artifact should be appended to a previously sent + // artifact with the same ID. + Append *bool `json:"append,omitempty" yaml:"append,omitempty" mapstructure:"append,omitempty"` + + // The artifact that was generated or updated. + Artifact Artifact `json:"artifact" yaml:"artifact" mapstructure:"artifact"` + + // A collection of artifacts generated by the agent during the execution of the + // task. + Artifacts []Artifact `json:"artifacts,omitempty" yaml:"artifacts,omitempty" mapstructure:"artifacts,omitempty"` + + // A server-generated identifier for maintaining context across multiple related + // tasks or interactions. + ContextId string `json:"contextId" yaml:"contextId" mapstructure:"contextId"` + + // The URIs of extensions that are relevant to this message. + Extensions []string `json:"extensions,omitempty" yaml:"extensions,omitempty" mapstructure:"extensions,omitempty"` + + // If true, this is the final event in the stream for this interaction. + Final bool `json:"final" yaml:"final" mapstructure:"final"` + + // An array of messages exchanged during the task, representing the conversation + // history. + History []Message `json:"history,omitempty" yaml:"history,omitempty" mapstructure:"history,omitempty"` + + // A unique identifier for the task, generated by the server for a new task. + Id string `json:"id" yaml:"id" mapstructure:"id"` + + // The type of this object, used as a discriminator. Always 'task' for a Task. + Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` + + // If true, this is the final chunk of the artifact. + LastChunk *bool `json:"lastChunk,omitempty" yaml:"lastChunk,omitempty" mapstructure:"lastChunk,omitempty"` + + // A unique identifier for the message, typically a UUID, generated by the sender. + MessageId string `json:"messageId" yaml:"messageId" mapstructure:"messageId"` + + // Optional metadata for extensions. The key is an extension-specific identifier. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` + + // An array of content parts that form the message body. A message can be + // composed of multiple parts of different types (e.g., text and files). + Parts []MessagePartsElem `json:"parts" yaml:"parts" mapstructure:"parts"` + + // A list of other task IDs that this message references for additional context. + ReferenceTaskIds []string `json:"referenceTaskIds,omitempty" yaml:"referenceTaskIds,omitempty" mapstructure:"referenceTaskIds,omitempty"` + + // Identifies the sender of the message. `user` for the client, `agent` for the + // service. + Role MessageRole `json:"role" yaml:"role" mapstructure:"role"` + + // The current status of the task, including its state and a descriptive message. + Status TaskStatus `json:"status" yaml:"status" mapstructure:"status"` + + // The identifier of the task this message is part of. Can be omitted for the + // first message of a new task. + TaskId string `json:"taskId" yaml:"taskId" mapstructure:"taskId"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *SendStreamingMessageSuccessResponseResult) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + var sendStreamingMessageSuccessResponseResult_0 SendStreamingMessageSuccessResponseResult_0 + var sendStreamingMessageSuccessResponseResult_1 SendStreamingMessageSuccessResponseResult_1 + var sendStreamingMessageSuccessResponseResult_2 SendStreamingMessageSuccessResponseResult_2 + var sendStreamingMessageSuccessResponseResult_3 SendStreamingMessageSuccessResponseResult_3 + var errs []error + if err := sendStreamingMessageSuccessResponseResult_0.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := sendStreamingMessageSuccessResponseResult_1.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := sendStreamingMessageSuccessResponseResult_2.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if err := sendStreamingMessageSuccessResponseResult_3.UnmarshalJSON(value); err != nil { + errs = append(errs, err) + } + if len(errs) == 4 { + return fmt.Errorf("all validators failed: %s", errors.Join(errs...)) + } + type Plain SendStreamingMessageSuccessResponseResult + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = SendStreamingMessageSuccessResponseResult(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *SendStreamingMessageSuccessResponse) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in SendStreamingMessageSuccessResponse: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in SendStreamingMessageSuccessResponse: required") + } + if _, ok := raw["result"]; raw != nil && !ok { + return fmt.Errorf("field result in SendStreamingMessageSuccessResponse: required") + } + type Plain SendStreamingMessageSuccessResponse + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = SendStreamingMessageSuccessResponse(plain) + return nil +} + +// Represents a JSON-RPC request for the `tasks/pushNotificationConfig/set` method. +type SetTaskPushNotificationConfigRequest struct { + // The identifier for this request. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The method name. Must be 'tasks/pushNotificationConfig/set'. + Method string `json:"method" yaml:"method" mapstructure:"method"` + + // The parameters for setting the push notification configuration. + Params TaskPushNotificationConfig `json:"params" yaml:"params" mapstructure:"params"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *SetTaskPushNotificationConfigRequest) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in SetTaskPushNotificationConfigRequest: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in SetTaskPushNotificationConfigRequest: required") + } + if _, ok := raw["method"]; raw != nil && !ok { + return fmt.Errorf("field method in SetTaskPushNotificationConfigRequest: required") + } + if _, ok := raw["params"]; raw != nil && !ok { + return fmt.Errorf("field params in SetTaskPushNotificationConfigRequest: required") + } + type Plain SetTaskPushNotificationConfigRequest + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = SetTaskPushNotificationConfigRequest(plain) + return nil +} + +// Represents a JSON-RPC response for the `tasks/pushNotificationConfig/set` +// method. +type SetTaskPushNotificationConfigResponse interface{} + +// Represents a successful JSON-RPC response for the +// `tasks/pushNotificationConfig/set` method. +type SetTaskPushNotificationConfigSuccessResponse struct { + // The identifier established by the client. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The result, containing the configured push notification settings. + Result TaskPushNotificationConfig `json:"result" yaml:"result" mapstructure:"result"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *SetTaskPushNotificationConfigSuccessResponse) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in SetTaskPushNotificationConfigSuccessResponse: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in SetTaskPushNotificationConfigSuccessResponse: required") + } + if _, ok := raw["result"]; raw != nil && !ok { + return fmt.Errorf("field result in SetTaskPushNotificationConfigSuccessResponse: required") + } + type Plain SetTaskPushNotificationConfigSuccessResponse + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = SetTaskPushNotificationConfigSuccessResponse(plain) + return nil +} + +// Represents a single, stateful operation or conversation between a client and an +// agent. +type Task struct { + // A collection of artifacts generated by the agent during the execution of the + // task. + Artifacts []Artifact `json:"artifacts,omitempty" yaml:"artifacts,omitempty" mapstructure:"artifacts,omitempty"` + + // A server-generated identifier for maintaining context across multiple related + // tasks or interactions. + ContextId string `json:"contextId" yaml:"contextId" mapstructure:"contextId"` + + // An array of messages exchanged during the task, representing the conversation + // history. + History []Message `json:"history,omitempty" yaml:"history,omitempty" mapstructure:"history,omitempty"` + + // A unique identifier for the task, generated by the server for a new task. + Id string `json:"id" yaml:"id" mapstructure:"id"` + + // The type of this object, used as a discriminator. Always 'task' for a Task. + Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` + + // Optional metadata for extensions. The key is an extension-specific identifier. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` + + // The current status of the task, including its state and a descriptive message. + Status TaskStatus `json:"status" yaml:"status" mapstructure:"status"` +} + +// An event sent by the agent to notify the client that an artifact has been +// generated or updated. This is typically used in streaming models. +type TaskArtifactUpdateEvent struct { + // If true, the content of this artifact should be appended to a previously sent + // artifact with the same ID. + Append *bool `json:"append,omitempty" yaml:"append,omitempty" mapstructure:"append,omitempty"` + + // The artifact that was generated or updated. + Artifact Artifact `json:"artifact" yaml:"artifact" mapstructure:"artifact"` + + // The context ID associated with the task. + ContextId string `json:"contextId" yaml:"contextId" mapstructure:"contextId"` + + // The type of this event, used as a discriminator. Always 'artifact-update'. + Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` + + // If true, this is the final chunk of the artifact. + LastChunk *bool `json:"lastChunk,omitempty" yaml:"lastChunk,omitempty" mapstructure:"lastChunk,omitempty"` + + // Optional metadata for extensions. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` + + // The ID of the task this artifact belongs to. + TaskId string `json:"taskId" yaml:"taskId" mapstructure:"taskId"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *TaskArtifactUpdateEvent) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["artifact"]; raw != nil && !ok { + return fmt.Errorf("field artifact in TaskArtifactUpdateEvent: required") + } + if _, ok := raw["contextId"]; raw != nil && !ok { + return fmt.Errorf("field contextId in TaskArtifactUpdateEvent: required") + } + if _, ok := raw["kind"]; raw != nil && !ok { + return fmt.Errorf("field kind in TaskArtifactUpdateEvent: required") + } + if _, ok := raw["taskId"]; raw != nil && !ok { + return fmt.Errorf("field taskId in TaskArtifactUpdateEvent: required") + } + type Plain TaskArtifactUpdateEvent + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = TaskArtifactUpdateEvent(plain) + return nil +} + +// Defines parameters containing a task ID, used for simple task operations. +type TaskIdParams struct { + // The unique identifier of the task. + Id string `json:"id" yaml:"id" mapstructure:"id"` + + // Optional metadata associated with the request. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *TaskIdParams) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in TaskIdParams: required") + } + type Plain TaskIdParams + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = TaskIdParams(plain) + return nil +} + +// An A2A-specific error indicating that the task is in a state where it cannot be +// canceled. +type TaskNotCancelableError struct { + // The error code for a task that cannot be canceled. + Code int `json:"code" yaml:"code" mapstructure:"code"` + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` + + // The error message. + Message string `json:"message" yaml:"message" mapstructure:"message"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *TaskNotCancelableError) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["code"]; raw != nil && !ok { + return fmt.Errorf("field code in TaskNotCancelableError: required") + } + type Plain TaskNotCancelableError + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + if v, ok := raw["message"]; !ok || v == nil { + plain.Message = "Task cannot be canceled" + } + *j = TaskNotCancelableError(plain) + return nil +} + +// An A2A-specific error indicating that the requested task ID was not found. +type TaskNotFoundError struct { + // The error code for a task not found error. + Code int `json:"code" yaml:"code" mapstructure:"code"` + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` + + // The error message. + Message string `json:"message" yaml:"message" mapstructure:"message"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *TaskNotFoundError) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["code"]; raw != nil && !ok { + return fmt.Errorf("field code in TaskNotFoundError: required") + } + type Plain TaskNotFoundError + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + if v, ok := raw["message"]; !ok || v == nil { + plain.Message = "Task not found" + } + *j = TaskNotFoundError(plain) + return nil +} + +// A container associating a push notification configuration with a specific task. +type TaskPushNotificationConfig struct { + // The push notification configuration for this task. + PushNotificationConfig PushNotificationConfig `json:"pushNotificationConfig" yaml:"pushNotificationConfig" mapstructure:"pushNotificationConfig"` + + // The ID of the task. + TaskId string `json:"taskId" yaml:"taskId" mapstructure:"taskId"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *TaskPushNotificationConfig) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["pushNotificationConfig"]; raw != nil && !ok { + return fmt.Errorf("field pushNotificationConfig in TaskPushNotificationConfig: required") + } + if _, ok := raw["taskId"]; raw != nil && !ok { + return fmt.Errorf("field taskId in TaskPushNotificationConfig: required") + } + type Plain TaskPushNotificationConfig + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = TaskPushNotificationConfig(plain) + return nil +} + +// Defines parameters for querying a task, with an option to limit history length. +type TaskQueryParams struct { + // The number of most recent messages from the task's history to retrieve. + HistoryLength *int `json:"historyLength,omitempty" yaml:"historyLength,omitempty" mapstructure:"historyLength,omitempty"` + + // The unique identifier of the task. + Id string `json:"id" yaml:"id" mapstructure:"id"` + + // Optional metadata associated with the request. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *TaskQueryParams) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in TaskQueryParams: required") + } + type Plain TaskQueryParams + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = TaskQueryParams(plain) + return nil +} + +// Represents a JSON-RPC request for the `tasks/resubscribe` method, used to resume +// a streaming connection. +type TaskResubscriptionRequest struct { + // The identifier for this request. + Id interface{} `json:"id" yaml:"id" mapstructure:"id"` + + // The version of the JSON-RPC protocol. MUST be exactly "2.0". + Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` + + // The method name. Must be 'tasks/resubscribe'. + Method string `json:"method" yaml:"method" mapstructure:"method"` + + // The parameters identifying the task to resubscribe to. + Params TaskIdParams `json:"params" yaml:"params" mapstructure:"params"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *TaskResubscriptionRequest) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in TaskResubscriptionRequest: required") + } + if _, ok := raw["jsonrpc"]; raw != nil && !ok { + return fmt.Errorf("field jsonrpc in TaskResubscriptionRequest: required") + } + if _, ok := raw["method"]; raw != nil && !ok { + return fmt.Errorf("field method in TaskResubscriptionRequest: required") + } + if _, ok := raw["params"]; raw != nil && !ok { + return fmt.Errorf("field params in TaskResubscriptionRequest: required") + } + type Plain TaskResubscriptionRequest + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = TaskResubscriptionRequest(plain) + return nil +} + +type TaskState string + +const TaskStateAuthRequired TaskState = "auth-required" +const TaskStateCanceled TaskState = "canceled" +const TaskStateCompleted TaskState = "completed" +const TaskStateFailed TaskState = "failed" +const TaskStateInputRequired TaskState = "input-required" +const TaskStateRejected TaskState = "rejected" +const TaskStateSubmitted TaskState = "submitted" +const TaskStateUnknown TaskState = "unknown" +const TaskStateWorking TaskState = "working" + +var enumValues_TaskState = []interface{}{ + "submitted", + "working", + "input-required", + "completed", + "canceled", + "failed", + "rejected", + "auth-required", + "unknown", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *TaskState) UnmarshalJSON(value []byte) error { + var v string + if err := json.Unmarshal(value, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_TaskState { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_TaskState, v) + } + *j = TaskState(v) + return nil +} + +// Represents the status of a task at a specific point in time. +type TaskStatus struct { + // An optional, human-readable message providing more details about the current + // status. + Message *Message `json:"message,omitempty" yaml:"message,omitempty" mapstructure:"message,omitempty"` + + // The current state of the task's lifecycle. + State TaskState `json:"state" yaml:"state" mapstructure:"state"` + + // An ISO 8601 datetime string indicating when this status was recorded. + Timestamp *string `json:"timestamp,omitempty" yaml:"timestamp,omitempty" mapstructure:"timestamp,omitempty"` +} + +// An event sent by the agent to notify the client of a change in a task's status. +// This is typically used in streaming or subscription models. +type TaskStatusUpdateEvent struct { + // The context ID associated with the task. + ContextId string `json:"contextId" yaml:"contextId" mapstructure:"contextId"` + + // If true, this is the final event in the stream for this interaction. + Final bool `json:"final" yaml:"final" mapstructure:"final"` + + // The type of this event, used as a discriminator. Always 'status-update'. + Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` + + // Optional metadata for extensions. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` + + // The new status of the task. + Status TaskStatus `json:"status" yaml:"status" mapstructure:"status"` + + // The ID of the task that was updated. + TaskId string `json:"taskId" yaml:"taskId" mapstructure:"taskId"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *TaskStatusUpdateEvent) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["contextId"]; raw != nil && !ok { + return fmt.Errorf("field contextId in TaskStatusUpdateEvent: required") + } + if _, ok := raw["final"]; raw != nil && !ok { + return fmt.Errorf("field final in TaskStatusUpdateEvent: required") + } + if _, ok := raw["kind"]; raw != nil && !ok { + return fmt.Errorf("field kind in TaskStatusUpdateEvent: required") + } + if _, ok := raw["status"]; raw != nil && !ok { + return fmt.Errorf("field status in TaskStatusUpdateEvent: required") + } + if _, ok := raw["taskId"]; raw != nil && !ok { + return fmt.Errorf("field taskId in TaskStatusUpdateEvent: required") + } + type Plain TaskStatusUpdateEvent + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = TaskStatusUpdateEvent(plain) + return nil +} + +type JSONRPCErrorResponseError_9 = UnsupportedOperationError +type SendMessageSuccessResponseResult_0 = Task + +// UnmarshalJSON implements json.Unmarshaler. +func (j *UnsupportedOperationError) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["code"]; raw != nil && !ok { + return fmt.Errorf("field code in UnsupportedOperationError: required") + } + type Plain UnsupportedOperationError + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + if v, ok := raw["message"]; !ok || v == nil { + plain.Message = "This operation is not supported" + } + *j = UnsupportedOperationError(plain) + return nil +} + +// An A2A-specific error indicating that the requested operation is not supported +// by the agent. +type UnsupportedOperationError struct { + // The error code for an unsupported operation. + Code int `json:"code" yaml:"code" mapstructure:"code"` + + // A primitive or structured value containing additional information about the + // error. + // This may be omitted. + Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` + + // The error message. + Message string `json:"message" yaml:"message" mapstructure:"message"` +} + +type JSONRPCErrorResponseError_0 = JSONRPCError +type GetTaskPushNotificationConfigRequestParams_1 = GetTaskPushNotificationConfigParams +type GetTaskPushNotificationConfigRequestParams_0 = TaskIdParams +type JSONRPCErrorResponseError_12 = AuthenticatedExtendedCardNotConfiguredError +type FilePartFile_1 = FileWithUri +type FilePartFile_0 = FileWithBytes +type JSONRPCErrorResponseError_11 = InvalidAgentResponseError +type JSONRPCErrorResponseError_10 = ContentTypeNotSupportedError +type SendStreamingMessageSuccessResponseResult_0 = Task +type SendStreamingMessageSuccessResponseResult_1 = Message +type SendStreamingMessageSuccessResponseResult_2 = TaskStatusUpdateEvent +type SendStreamingMessageSuccessResponseResult_3 = TaskArtifactUpdateEvent +type SendMessageSuccessResponseResult_1 = Message +type JSONRPCErrorResponseError_8 = PushNotificationNotSupportedError +type JSONRPCErrorResponseError_7 = TaskNotCancelableError +type JSONRPCErrorResponseError_6 = TaskNotFoundError +type JSONRPCErrorResponseError_5 = InternalError +type JSONRPCErrorResponseError_4 = InvalidParamsError +type JSONRPCErrorResponseError_3 = MethodNotFoundError +type JSONRPCErrorResponseError_2 = InvalidRequestError +type JSONRPCErrorResponseError_1 = JSONParseError + +// UnmarshalJSON implements json.Unmarshaler. +func (j *Task) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["contextId"]; raw != nil && !ok { + return fmt.Errorf("field contextId in Task: required") + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in Task: required") + } + if _, ok := raw["kind"]; raw != nil && !ok { + return fmt.Errorf("field kind in Task: required") + } + if _, ok := raw["status"]; raw != nil && !ok { + return fmt.Errorf("field status in Task: required") + } + type Plain Task + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = Task(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *TaskStatus) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["state"]; raw != nil && !ok { + return fmt.Errorf("field state in TaskStatus: required") + } + type Plain TaskStatus + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = TaskStatus(plain) + return nil +} + +// Represents a text segment within a message or artifact. +type TextPart struct { + // The type of this part, used as a discriminator. Always 'text'. + Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` + + // Optional metadata associated with this part. + Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` + + // The string content of the text part. + Text string `json:"text" yaml:"text" mapstructure:"text"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *TextPart) UnmarshalJSON(value []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(value, &raw); err != nil { + return err + } + if _, ok := raw["kind"]; raw != nil && !ok { + return fmt.Errorf("field kind in TextPart: required") + } + if _, ok := raw["text"]; raw != nil && !ok { + return fmt.Errorf("field text in TextPart: required") + } + type Plain TextPart + var plain Plain + if err := json.Unmarshal(value, &plain); err != nil { + return err + } + *j = TextPart(plain) + return nil +} + +type TransportProtocol string + +var enumValues_TransportProtocol = []interface{}{ + "JSONRPC", + "GRPC", + "HTTP+JSON", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *TransportProtocol) UnmarshalJSON(value []byte) error { + var v string + if err := json.Unmarshal(value, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_TransportProtocol { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_TransportProtocol, v) + } + *j = TransportProtocol(v) + return nil +} + +const TransportProtocolJSONRPC TransportProtocol = "JSONRPC" +const TransportProtocolGRPC TransportProtocol = "GRPC" +const TransportProtocolHTTPJSON TransportProtocol = "HTTP+JSON" diff --git a/internal/push/sender.go b/internal/push/sender.go new file mode 100644 index 00000000..ef816f95 --- /dev/null +++ b/internal/push/sender.go @@ -0,0 +1,3 @@ +package push + +type HTTPPushSender struct{} diff --git a/internal/push/store.go b/internal/push/store.go new file mode 100644 index 00000000..73dbed67 --- /dev/null +++ b/internal/push/store.go @@ -0,0 +1,3 @@ +package push + +type InMemoryPushConfigStore struct{} diff --git a/internal/task/store.go b/internal/task/store.go new file mode 100644 index 00000000..be143ff3 --- /dev/null +++ b/internal/task/store.go @@ -0,0 +1,3 @@ +package task + +type InMemoryTaskStore struct{} From 7239ade3c43f7cbabcd5e27a8b2394eb7849a418 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Wed, 6 Aug 2025 16:41:22 +0000 Subject: [PATCH 06/23] replace chan with seq --- a2asrv/handler.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/a2asrv/handler.go b/a2asrv/handler.go index 2b1e7912..ecce66a7 100644 --- a/a2asrv/handler.go +++ b/a2asrv/handler.go @@ -2,6 +2,7 @@ package a2asrv import ( "context" + "iter" "github.com/a2aproject/a2a-go/a2a" ) @@ -13,9 +14,9 @@ type RequestHandler interface { OnHandleSendMessage(ctx context.Context, message a2a.MessageSendParams) (a2a.SendMessageResponse, error) - OnHandleResubscribeToTask(ctx context.Context, id a2a.TaskIDParams) (<-chan a2a.Event, error) + OnHandleResubscribeToTask(ctx context.Context, id a2a.TaskIDParams) iter.Seq2[a2a.Event, error] - OnHandleSendMessageStream(ctx context.Context, message a2a.MessageSendParams) (<-chan a2a.Event, error) + OnHandleSendMessageStream(ctx context.Context, message a2a.MessageSendParams) iter.Seq2[a2a.Event, error] OnHandleGetTaskPushConfig(ctx context.Context, params a2a.GetTaskPushNotificationConfigParams) (a2a.GetTaskPushNotificationConfigResponse, error) From 35cec6ec0521d8197c5325bc63aefdad8f6262f8 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Wed, 6 Aug 2025 19:00:06 +0000 Subject: [PATCH 07/23] remove duplicated files and split types file into many --- a2a/agent.go | 208 +++++++++++ a2a/auth.go | 169 +++++++++ a2a/errors.go | 20 +- a2a/push.go | 83 +++++ a2a/types.go | 894 ++++++++-------------------------------------- a2asrv/handler.go | 12 +- 6 files changed, 627 insertions(+), 759 deletions(-) create mode 100644 a2a/agent.go create mode 100644 a2a/auth.go create mode 100644 a2a/push.go diff --git a/a2a/agent.go b/a2a/agent.go new file mode 100644 index 00000000..23d66dee --- /dev/null +++ b/a2a/agent.go @@ -0,0 +1,208 @@ +package a2a + +// Defines optional capabilities supported by an agent. +type AgentCapabilities struct { + // A list of protocol extensions supported by the agent. + Extensions []AgentExtension + + // Indicates if the agent supports sending push notifications for asynchronous + // task updates. + PushNotifications *bool + + // Indicates if the agent provides a history of state transitions for a task. + StateTransitionHistory *bool + + // Indicates if the agent supports Server-Sent Events (SSE) for streaming + // responses. + Streaming *bool +} + +// The AgentCard is a self-describing manifest for an agent. It provides essential +// metadata including the agent's identity, capabilities, skills, supported +// communication methods, and security requirements. +type AgentCard struct { + // A list of additional supported interfaces (transport and URL combinations). + // This allows agents to expose multiple transports, potentially at different + // URLs. + // + // Best practices: + // - SHOULD include all supported transports for completeness + // - SHOULD include an entry matching the main 'url' and 'preferredTransport' + // - MAY reuse URLs if multiple transports are available at the same endpoint + // - MUST accurately declare the transport available at each URL + // + // Clients can select any interface from this list based on their transport + // capabilities + // and preferences. This enables transport negotiation and fallback scenarios. + AdditionalInterfaces []AgentInterface + + // A declaration of optional capabilities supported by the agent. + Capabilities AgentCapabilities + + // Default set of supported input MIME types for all skills, which can be + // overridden on a per-skill basis. + DefaultInputModes []string + + // Default set of supported output MIME types for all skills, which can be + // overridden on a per-skill basis. + DefaultOutputModes []string + + // A human-readable description of the agent, assisting users and other agents + // in understanding its purpose. + Description string + + // An optional URL to the agent's documentation. + DocumentationURL *string + + // An optional URL to an icon for the agent. + IconURL *string + + // A human-readable name for the agent. + Name string + + // The transport protocol for the preferred endpoint (the main 'url' field). + // If not specified, defaults to 'JSONRPC'. + // + // IMPORTANT: The transport specified here MUST be available at the main 'url'. + // This creates a binding between the main URL and its supported transport + // protocol. + // Clients should prefer this transport and URL combination when both are + // supported. + PreferredTransport TransportProtocol + + // The version of the A2A protocol this agent supports. + ProtocolVersion string + + // Information about the agent's service provider. + Provider *AgentProvider + + // A list of security requirement objects that apply to all agent interactions. + // Each object + // lists security schemes that can be used. Follows the OpenAPI 3.0 Security + // Requirement Object. + // This list can be seen as an OR of ANDs. Each object in the list describes one + // possible + // set of security requirements that must be present on a request. This allows + // specifying, + // for example, "callers must either use OAuth OR an API Key AND mTLS." + Security []map[string][]string + + // A declaration of the security schemes available to authorize requests. The key + // is the + // scheme name. Follows the OpenAPI 3.0 Security Scheme Object. + SecuritySchemes map[string]any + + // JSON Web Signatures computed for this AgentCard. + Signatures []AgentCardSignature + + // The set of skills, or distinct capabilities, that the agent can perform. + Skills []AgentSkill + + // If true, the agent can provide an extended agent card with additional details + // to authenticated users. Defaults to false. + SupportsAuthenticatedExtendedCard *bool + + // The preferred endpoint URL for interacting with the agent. + // This URL MUST support the transport specified by 'preferredTransport'. + URL string + + // The agent's own version number. The format is defined by the provider. + Version string +} + +// AgentCardSignature represents a JWS signature of an AgentCard. +// This follows the JSON format of an RFC 7515 JSON Web Signature (JWS). +type AgentCardSignature struct { + // The unprotected JWS header values. + Header map[string]any + + // The protected JWS header for the signature. This is a Base64url-encoded + // JSON object, as per RFC 7515. + Protected string + + // The computed signature, Base64url-encoded. + Signature string +} + +// A declaration of a protocol extension supported by an Agent. +type AgentExtension struct { + // A human-readable description of how this agent uses the extension. + Description *string + + // Optional, extension-specific configuration parameters. + Params map[string]any + + // If true, the client must understand and comply with the extension's + // requirements + // to interact with the agent. + Required *bool + + // The unique URI identifying the extension. + Uri string +} + +// Declares a combination of a target URL and a transport protocol for interacting +// with the agent. +// This allows agents to expose the same functionality over multiple transport +// mechanisms. +type AgentInterface struct { + // The transport protocol supported at this URL. + Transport string + + // The URL where this interface is available. Must be a valid absolute HTTPS URL + // in production. + URL string +} + +// Represents the service provider of an agent. +type AgentProvider struct { + // The name of the agent provider's organization. + Org string + + // A URL for the agent provider's website or relevant documentation. + URL string +} + +// Represents a distinct capability or function that an agent can perform. +type AgentSkill struct { + // A detailed description of the skill, intended to help clients or users + // understand its purpose and functionality. + Description string + + // Example prompts or scenarios that this skill can handle. Provides a hint to + // the client on how to use the skill. + Examples []string + + // A unique identifier for the agent's skill. + ID string + + // The set of supported input MIME types for this skill, overriding the agent's + // defaults. + InputModes []string + + // A human-readable name for the skill. + Name string + + // The set of supported output MIME types for this skill, overriding the agent's + // defaults. + OutputModes []string + + // Security schemes necessary for the agent to leverage this skill. + // As in the overall AgentCard.security, this list represents a logical OR of + // security + // requirement objects. Each object is a set of security schemes that must be used + // together + // (a logical AND). + Security []map[string][]string + + // A set of keywords describing the skill's capabilities. + Tags []string +} + +type TransportProtocol string + +const ( + TransportProtocolJSONRPC TransportProtocol = "JSONRPC" + TransportProtocolGRPC TransportProtocol = "GRPC" + TransportProtocolHTTPJSON TransportProtocol = "HTTP+JSON" +) diff --git a/a2a/auth.go b/a2a/auth.go new file mode 100644 index 00000000..54e32ace --- /dev/null +++ b/a2a/auth.go @@ -0,0 +1,169 @@ +package a2a + +// Defines a security scheme that can be used to secure an agent's endpoints. +// This is a discriminated union type based on the OpenAPI 3.0 Security Scheme. +type SecurityScheme interface { + isSecurityScheme() +} + +func (APIKeySecurityScheme) isSecurityScheme() {} +func (HTTPAuthSecurityScheme) isSecurityScheme() {} +func (OpenIDConnectSecurityScheme) isSecurityScheme() {} +func (MutualTLSSecurityScheme) isSecurityScheme() {} +func (OAuth2SecurityScheme) isSecurityScheme() {} + +// Defines a security scheme using an API key. +type APIKeySecurityScheme struct { + // An optional description for the security scheme. + Description *string + + // The location of the API key. + In APIKeySecuritySchemeIn + + // The name of the header, query, or cookie parameter to be used. + Name string + + // The type of the security scheme. Must be 'apiKey'. + Type string +} + +type APIKeySecuritySchemeIn string + +const ( + APIKeySecuritySchemeInCookie APIKeySecuritySchemeIn = "cookie" + APIKeySecuritySchemeInHeader APIKeySecuritySchemeIn = "header" + APIKeySecuritySchemeInQuery APIKeySecuritySchemeIn = "query" +) + +// Defines configuration details for the OAuth 2.0 Authorization Code flow. +type AuthzCodeOAuthFlow struct { + // The authorization URL to be used for this flow. + // This MUST be a URL and use TLS. + AuthzURL string + + // The URL to be used for obtaining refresh tokens. + // This MUST be a URL and use TLS. + RefreshURL *string + + // The available scopes for the OAuth2 security scheme. A map between the scope + // name and a short description for it. + Scopes map[string]string + + // The token URL to be used for this flow. + // This MUST be a URL and use TLS. + TokenURL string +} + +// Defines configuration details for the OAuth 2.0 Client Credentials flow. +type ClientCredentialsOAuthFlow struct { + // The URL to be used for obtaining refresh tokens. This MUST be a URL. + RefreshURL *string + + // The available scopes for the OAuth2 security scheme. A map between the scope + // name and a short description for it. + Scopes map[string]string + + // The token URL to be used for this flow. This MUST be a URL. + TokenURL string +} + +// Defines a security scheme using HTTP authentication. +type HTTPAuthSecurityScheme struct { + // A hint to the client to identify how the bearer token is formatted (e.g., + // "JWT"). + // This is primarily for documentation purposes. + BearerFormat *string + + // An optional description for the security scheme. + Description *string + + // The name of the HTTP Authentication scheme to be used in the Authorization + // header, + // as defined in RFC7235 (e.g., "Bearer"). + // This value should be registered in the IANA Authentication Scheme registry. + Scheme string + + // The type of the security scheme. Must be 'http'. + Type string +} + +// Defines configuration details for the OAuth 2.0 Implicit flow. +type ImplicitOAuthFlow struct { + // The authorization URL to be used for this flow. This MUST be a URL. + AuthzURL string + + // The URL to be used for obtaining refresh tokens. This MUST be a URL. + RefreshURL *string + + // The available scopes for the OAuth2 security scheme. A map between the scope + // name and a short description for it. + Scopes map[string]string +} + +// Defines a security scheme using mTLS authentication. +type MutualTLSSecurityScheme struct { + // An optional description for the security scheme. + Description *string + + // The type of the security scheme. Must be 'mutualTLS'. + Type string +} + +// Defines a security scheme using OAuth 2.0. +type OAuth2SecurityScheme struct { + // An optional description for the security scheme. + Description *string + + // An object containing configuration information for the supported OAuth 2.0 + // flows. + Flows OAuthFlows + + // URL to the oauth2 authorization server metadata + // [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414). TLS is required. + Oauth2MetadataURL *string + + // The type of the security scheme. Must be 'oauth2'. + Type string +} + +// Defines the configuration for the supported OAuth 2.0 flows. +type OAuthFlows struct { + // Configuration for the OAuth Authorization Code flow. Previously called + // accessCode in OpenAPI 2.0. + AuthzCode *AuthzCodeOAuthFlow + + // Configuration for the OAuth Client Credentials flow. Previously called + // application in OpenAPI 2.0. + ClientCredentials *ClientCredentialsOAuthFlow + + // Configuration for the OAuth Implicit flow. + Implicit *ImplicitOAuthFlow + + // Configuration for the OAuth Resource Owner Password flow. + Password *PasswordOAuthFlow +} + +// Defines a security scheme using OpenID Connect. +type OpenIDConnectSecurityScheme struct { + // An optional description for the security scheme. + Description *string + + // The OpenID Connect Discovery URL for the OIDC provider's metadata. + OpenIDConnectURL string + + // The type of the security scheme. Must be 'openIDConnect'. + Type string +} + +// Defines configuration details for the OAuth 2.0 Resource Owner Password flow. +type PasswordOAuthFlow struct { + // The URL to be used for obtaining refresh tokens. This MUST be a URL. + RefreshURL *string + + // The available scopes for the OAuth2 security scheme. A map between the scope + // name and a short description for it. + Scopes map[string]string + + // The token URL to be used for this flow. This MUST be a URL. + TokenURL string +} diff --git a/a2a/errors.go b/a2a/errors.go index 8b4bdb67..b3f6843a 100644 --- a/a2a/errors.go +++ b/a2a/errors.go @@ -1,17 +1,21 @@ package a2a -import "fmt" +import "errors" -var ErrTaskNotFound = fmt.Errorf("task not found") +var ( + ErrTaskNotFound = errors.New("task not found") -var ErrTaskNotCancelable = fmt.Errorf("task cannot be canceled") + ErrTaskNotCancelable = errors.New("task cannot be canceled") -var ErrPushNotificationNotSupported = fmt.Errorf("push notification not supported") + ErrPushNotificationNotSupported = errors.New("push notification not supported") -var ErrUnsupportedOperation = fmt.Errorf("this operation is not supported") + ErrUnsupportedOperation = errors.New("this operation is not supported") -var ErrUnsupportedContentType = fmt.Errorf("incompatible content types") + ErrUnsupportedContentType = errors.New("incompatible content types") -var ErrInvalidAgentResponse = fmt.Errorf("invalid agent response") + ErrInvalidAgentResponse = errors.New("invalid agent response") -var ErrInvalidRequest = fmt.Errorf("invalid request") + ErrInvalidRequest = errors.New("invalid request") + + ErrAuthenticatedExtendedCardNotConfigured = errors.New("") +) diff --git a/a2a/push.go b/a2a/push.go new file mode 100644 index 00000000..63a2a47a --- /dev/null +++ b/a2a/push.go @@ -0,0 +1,83 @@ +package a2a + +// Defines parameters for fetching a specific push notification configuration for a task. +type GetTaskPushConfigParams struct { + // The unique identifier of the task. + TaskID TaskID + + // The ID of the push notification configuration to retrieve. + ConfigID *string + + // Optional metadata associated with the request. + Metadata map[string]any +} + +// Defines parameters for listing all push notification configurations associated +// with a task. +type ListTaskPushConfigParams struct { + // The unique identifier of the task. + TaskID TaskID + + // Optional metadata associated with the request. + Metadata map[string]any +} + +// Represents a request for the `tasks/pushNotificationConfig/set` method. +type SetTaskPushConfigParams struct { + // The parameters for setting the push notification configuration. + Config TaskPushConfig +} + +// Represents a config update result +type SetTaskPushConfigResult struct { + // The result, containing the configured push notification settings. + Config TaskPushConfig +} + +// Defines parameters for deleting a specific push notification configuration for a task. +type DeleteTaskPushConfigParams struct { + // The unique identifier of the task. + TaskID TaskID + + // Optional metadata associated with the request. + Metadata map[string]any + + // The ID of the push notification configuration to delete. + ConfigID string +} + +// A container associating a push notification configuration with a specific task. +type TaskPushConfig struct { + // The push notification configuration for this task. + PushConfig PushConfig + + // The ID of the task. + TaskID TaskID +} + +// Defines the configuration for setting up push notifications for task updates. +type PushConfig struct { + // Optional authentication details for the agent to use when calling the + // notification URL. + Auth *PushAuthInfo + + // A unique ID for the push notification configuration, set by the client + // to support multiple notification callbacks. + ID *string + + // A unique token for this task or session to validate incoming push + // notifications. + Token *string + + // The callback URL where the agent should send push notifications. + URL string +} + +// Defines authentication details for a push notification endpoint. +type PushAuthInfo struct { + // Optional credentials required by the push notification endpoint. + Credentials *string + + // A list of supported authentication schemes (e.g., 'Basic', 'Bearer'). + Schemes []string +} diff --git a/a2a/types.go b/a2a/types.go index e24ffbc0..97f5dcfd 100644 --- a/a2a/types.go +++ b/a2a/types.go @@ -1,225 +1,119 @@ package a2a -// Defines a security scheme using an API key. -type APIKeySecurityScheme struct { - // An optional description for the security scheme. - Description *string - - // The location of the API key. - In APIKeySecuritySchemeIn +// Represents a response for non-streaming message send. +type SendMessageResult interface { + isSendMessageResult() +} - // The name of the header, query, or cookie parameter to be used. - Name string +func (Task) isSendMessageResult() {} +func (Message) isSendMessageResult() {} - // The type of the security scheme. Must be 'apiKey'. - Type string +// Event interface is used to represent types that can be sent over a streaming connection. +type Event interface { + isEvent() } -type APIKeySecuritySchemeIn string +func (t Message) isEvent() {} +func (t Task) isEvent() {} +func (t TaskStatusUpdateEvent) isEvent() {} +func (t TaskArtifactUpdateEvent) isEvent() {} + +type MessageRole string const ( - APIKeySecuritySchemeInCookie APIKeySecuritySchemeIn = "cookie" - APIKeySecuritySchemeInHeader APIKeySecuritySchemeIn = "header" - APIKeySecuritySchemeInQuery APIKeySecuritySchemeIn = "query" + MessageRoleAgent MessageRole = "agent" + MessageRoleUser MessageRole = "user" ) -// Defines optional capabilities supported by an agent. -type AgentCapabilities struct { - // A list of protocol extensions supported by the agent. - Extensions []AgentExtension - - // Indicates if the agent supports sending push notifications for asynchronous - // task updates. - PushNotifications *bool +// Represents a single message in the conversation between a user and an agent. +type Message struct { + // The context identifier for this message, used to group related interactions. + ContextID *string - // Indicates if the agent provides a history of state transitions for a task. - StateTransitionHistory *bool + // The URIs of extensions that are relevant to this message. + Extensions []string - // Indicates if the agent supports Server-Sent Events (SSE) for streaming - // responses. - Streaming *bool -} + // The type of this object, used as a discriminator. Always 'message' for a + // Message. + Kind string -// The AgentCard is a self-describing manifest for an agent. It provides essential -// metadata including the agent's identity, capabilities, skills, supported -// communication methods, and security requirements. -type AgentCard struct { - // A list of additional supported interfaces (transport and URL combinations). - // This allows agents to expose multiple transports, potentially at different - // URLs. - // - // Best practices: - // - SHOULD include all supported transports for completeness - // - SHOULD include an entry matching the main 'url' and 'preferredTransport' - // - MAY reuse URLs if multiple transports are available at the same endpoint - // - MUST accurately declare the transport available at each URL - // - // Clients can select any interface from this list based on their transport - // capabilities - // and preferences. This enables transport negotiation and fallback scenarios. - AdditionalInterfaces []AgentInterface - - // A declaration of optional capabilities supported by the agent. - Capabilities AgentCapabilities - - // Default set of supported input MIME types for all skills, which can be - // overridden on a per-skill basis. - DefaultInputModes []string - - // Default set of supported output MIME types for all skills, which can be - // overridden on a per-skill basis. - DefaultOutputModes []string - - // A human-readable description of the agent, assisting users and other agents - // in understanding its purpose. - Description string - - // An optional URL to the agent's documentation. - DocumentationURL *string - - // An optional URL to an icon for the agent. - IconURL *string - - // A human-readable name for the agent. - Name string - - // The transport protocol for the preferred endpoint (the main 'url' field). - // If not specified, defaults to 'JSONRPC'. - // - // IMPORTANT: The transport specified here MUST be available at the main 'url'. - // This creates a binding between the main URL and its supported transport - // protocol. - // Clients should prefer this transport and URL combination when both are - // supported. - PreferredTransport string - - // The version of the A2A protocol this agent supports. - ProtocolVersion string - - // Information about the agent's service provider. - Provider *AgentProvider - - // A list of security requirement objects that apply to all agent interactions. - // Each object - // lists security schemes that can be used. Follows the OpenAPI 3.0 Security - // Requirement Object. - // This list can be seen as an OR of ANDs. Each object in the list describes one - // possible - // set of security requirements that must be present on a request. This allows - // specifying, - // for example, "callers must either use OAuth OR an API Key AND mTLS." - Security []map[string][]string - - // A declaration of the security schemes available to authorize requests. The key - // is the - // scheme name. Follows the OpenAPI 3.0 Security Scheme Object. - SecuritySchemes map[string]any - - // JSON Web Signatures computed for this AgentCard. - Signatures []AgentCardSignature - - // The set of skills, or distinct capabilities, that the agent can perform. - Skills []AgentSkill - - // If true, the agent can provide an extended agent card with additional details - // to authenticated users. Defaults to false. - SupportsAuthenticatedExtendedCard *bool - - // The preferred endpoint URL for interacting with the agent. - // This URL MUST support the transport specified by 'preferredTransport'. - URL string - - // The agent's own version number. The format is defined by the provider. - Version string -} + // A unique identifier for the message, typically a UUID, generated by the sender. + MessageID string -// AgentCardSignature represents a JWS signature of an AgentCard. -// This follows the JSON format of an RFC 7515 JSON Web Signature (JWS). -type AgentCardSignature struct { - // The unprotected JWS header values. - Header map[string]any + // Optional metadata for extensions. The key is an extension-specific identifier. + Metadata map[string]any - // The protected JWS header for the signature. This is a Base64url-encoded - // JSON object, as per RFC 7515. - Protected string + // An array of content parts that form the message body. A message can be + // composed of multiple parts of different types (e.g., text and files). + Parts []Part - // The computed signature, Base64url-encoded. - Signature string -} + // A list of other task IDs that this message references for additional context. + ReferenceTasks []TaskID -// A declaration of a protocol extension supported by an Agent. -type AgentExtension struct { - // A human-readable description of how this agent uses the extension. - Description *string + // Identifies the sender of the message. + // service. + Role MessageRole - // Optional, extension-specific configuration parameters. - Params map[string]any + // The identifier of the task this message is part of. Can be omitted for the + // first message of a new task. + TaskID *TaskID +} - // If true, the client must understand and comply with the extension's - // requirements - // to interact with the agent. - Required *bool +type TaskID string - // The unique URI identifying the extension. - Uri string -} +type TaskState string -// Declares a combination of a target URL and a transport protocol for interacting -// with the agent. -// This allows agents to expose the same functionality over multiple transport -// mechanisms. -type AgentInterface struct { - // The transport protocol supported at this URL. - Transport string - - // The URL where this interface is available. Must be a valid absolute HTTPS URL - // in production. - URL string -} +const ( + TaskStateAuthRequired TaskState = "auth-required" + TaskStateCanceled TaskState = "canceled" + TaskStateCompleted TaskState = "completed" + TaskStateFailed TaskState = "failed" + TaskStateInputRequired TaskState = "input-required" + TaskStateRejected TaskState = "rejected" + TaskStateSubmitted TaskState = "submitted" + TaskStateUnknown TaskState = "unknown" + TaskStateWorking TaskState = "working" +) -// Represents the service provider of an agent. -type AgentProvider struct { - // The name of the agent provider's organization. - Org string +// Represents a single, stateful operation or conversation between a client and an +// agent. +type Task struct { + // A collection of artifacts generated by the agent during the execution of the + // task. + Artifacts []Artifact - // A URL for the agent provider's website or relevant documentation. - URL string -} + // A server-generated identifier for maintaining context across multiple related + // tasks or interactions. + ContextID string -// Represents a distinct capability or function that an agent can perform. -type AgentSkill struct { - // A detailed description of the skill, intended to help clients or users - // understand its purpose and functionality. - Description string + // An array of messages exchanged during the task, representing the conversation + // history. + History []Message - // Example prompts or scenarios that this skill can handle. Provides a hint to - // the client on how to use the skill. - Examples []string + // A unique identifier for the task, generated by the server for a new task. + ID TaskID - // A unique identifier for the agent's skill. - ID string + // The type of this object, used as a discriminator. Always 'task' for a Task. + Kind string - // The set of supported input MIME types for this skill, overriding the agent's - // defaults. - InputModes []string + // Optional metadata for extensions. The key is an extension-specific identifier. + Metadata map[string]any - // A human-readable name for the skill. - Name string + // The current status of the task, including its state and a descriptive message. + Status TaskStatus +} - // The set of supported output MIME types for this skill, overriding the agent's - // defaults. - OutputModes []string +// Represents the status of a task at a specific point in time. +type TaskStatus struct { + // An optional, human-readable message providing more details about the current + // status. + Message *Message - // Security schemes necessary for the agent to leverage this skill. - // As in the overall AgentCard.security, this list represents a logical OR of - // security - // requirement objects. Each object is a set of security schemes that must be used - // together - // (a logical AND). - Security []map[string][]string + // The current state of the task's lifecycle. + State TaskState - // A set of keywords describing the skill's capabilities. - Tags []string + // An ISO 8601 datetime string indicating when this status was recorded. + Timestamp *string } // Represents a file, data structure, or other resource generated by an agent @@ -241,67 +135,77 @@ type Artifact struct { Name *string // An array of content parts that make up the artifact. - Parts []ArtifactPartsElem + Parts []Part } -type ArtifactPartsElem interface{} -// An A2A-specific error indicating that the agent does not have an Authenticated -// Extended Card configured -type AuthenticatedExtendedCardNotConfiguredError struct { - // The error code for when an authenticated extended card is not configured. - Code int +// An event sent by the agent to notify the client that an artifact has been +// generated or updated. This is typically used in streaming models. +type TaskArtifactUpdateEvent struct { + // If true, the content of this artifact should be appended to a previously sent + // artifact with the same ID. + Append *bool - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data any + // The artifact that was generated or updated. + Artifact Artifact - // The error message. - Message string -} + // The context ID associated with the task. + ContextID string -// Defines configuration details for the OAuth 2.0 Authorization Code flow. -type AuthzCodeOAuthFlow struct { - // The authorization URL to be used for this flow. - // This MUST be a URL and use TLS. - AuthzURL string + // The type of this event, used as a discriminator. Always 'artifact-update'. + Kind string - // The URL to be used for obtaining refresh tokens. - // This MUST be a URL and use TLS. - RefreshURL *string + // If true, this is the final chunk of the artifact. + LastChunk *bool - // The available scopes for the OAuth2 security scheme. A map between the scope - // name and a short description for it. - Scopes map[string]string + // Optional metadata for extensions. + Metadata map[string]any - // The token URL to be used for this flow. - // This MUST be a URL and use TLS. - TokenURL string + // The ID of the task this artifact belongs to. + TaskID TaskID } -// Represents a request for the `tasks/cancel` method. -type CancelTaskRequest struct { - // The parameters identifying the task to cancel. - Params TaskIDParams +// An event sent by the agent to notify the client of a change in a task's status. +// This is typically used in streaming or subscription models. +type TaskStatusUpdateEvent struct { + // The context ID associated with the task. + ContextID string + + // If true, this is the final event in the stream for this interaction. + Final bool + + // The type of this event, used as a discriminator. Always 'status-update'. + Kind string + + // Optional metadata for extensions. + Metadata map[string]any + + // The new status of the task. + Status TaskStatus + + // The ID of the task that was updated. + TaskID TaskID } -// Represents a successful response for the `tasks/cancel` method. -type CancelTaskResponse struct { - // The result, containing the final state of the canceled Task object. - Result Task +// A discriminated union representing a part of a message or artifact, which can +// be text, a file, or structured data. +type Part interface { + isPart() } -// Defines configuration details for the OAuth 2.0 Client Credentials flow. -type ClientCredentialsOAuthFlow struct { - // The URL to be used for obtaining refresh tokens. This MUST be a URL. - RefreshURL *string +func (TextPart) isPart() {} +func (FilePart) isPart() {} +func (DataPart) isPart() {} + +// Represents a text segment within a message or artifact. +type TextPart struct { + // The type of this part, used as a discriminator. Always 'text'. + Kind string - // The available scopes for the OAuth2 security scheme. A map between the scope - // name and a short description for it. - Scopes map[string]string + // Optional metadata associated with this part. + Metadata map[string]any - // The token URL to be used for this flow. This MUST be a URL. - TokenURL string + // The string content of the text part. + Text string } // Represents a structured data segment (e.g., JSON) within a message or artifact. @@ -316,41 +220,6 @@ type DataPart struct { Metadata map[string]any } -// Defines parameters for deleting a specific push notification configuration for a -// task. -type DeleteTaskPushNotificationConfigParams struct { - // The unique identifier of the task. - ID string - - // Optional metadata associated with the request. - Metadata map[string]any - - // The ID of the push notification configuration to delete. - PushNotificationConfigID string -} - -// Represents a request for the `tasks/pushNotificationConfig/delete` -// method. -type DeleteTaskPushNotificationConfigRequest struct { - // The parameters identifying the push notification configuration to delete. - Params DeleteTaskPushNotificationConfigParams -} - -// Represents a successful response for the `tasks/pushNotificationConfig/delete` method. -type DeleteTaskPushNotificationConfigResponse struct { - // The result is null on successful deletion. - Result any -} - -// Defines base properties for a file. -type FileBase struct { - // The MIME type of the file (e.g., "application/pdf"). - MimeType *string - - // An optional name for the file (e.g., "document.pdf"). - Name *string -} - // Represents a file segment within a message or artifact. The file content can be // provided either directly as bytes or as a URI. type FilePart struct { @@ -403,173 +272,29 @@ type FileWithUri struct { Uri string } -// Represents a successful response for the `agent/getAuthenticatedExtendedCard` method. -type GetAuthenticatedExtendedCardResponse struct { - // The result is an Agent Card object. - Result AgentCard -} - -// Defines parameters for fetching a specific push notification configuration for a task. -type GetTaskPushNotificationConfigParams struct { - // The unique identifier of the task. - ID string - - // Optional metadata associated with the request. - Metadata map[string]any - - // The ID of the push notification configuration to retrieve. - PushNotificationConfigID *string -} - -// Represents a request for the `tasks/pushNotificationConfig/get` method. -type GetTaskPushNotificationConfigRequest struct { - // The parameters for getting a push notification configuration. - Params GetTaskPushNotificationConfigRequestParams -} +// Requests // Defines parameters containing a task ID, used for simple task operations. -type GetTaskPushNotificationConfigRequestParams struct { +type TaskIDParams struct { // The unique identifier of the task. - ID string + ID TaskID // Optional metadata associated with the request. Metadata map[string]any - - // The ID of the push notification configuration to retrieve. - PushNotificationConfigID *string -} - -// Represents a response for the `tasks/pushNotificationConfig/get` method. -type GetTaskPushNotificationConfigResponse struct { - // The result, containing the requested push notification configuration. - Result TaskPushConfig -} - -// Represents a request for the `tasks/get` method. -type GetTaskRequest struct { - // The parameters for querying a task. - Params TaskQueryParams -} - -// Represents a successful response for the `tasks/get` method. -type GetTaskResponse struct { - // The result, containing the requested Task object. - Result Task -} - -// Defines a security scheme using HTTP authentication. -type HTTPAuthSecurityScheme struct { - // A hint to the client to identify how the bearer token is formatted (e.g., - // "JWT"). - // This is primarily for documentation purposes. - BearerFormat *string - - // An optional description for the security scheme. - Description *string - - // The name of the HTTP Authentication scheme to be used in the Authorization - // header, - // as defined in RFC7235 (e.g., "Bearer"). - // This value should be registered in the IANA Authentication Scheme registry. - Scheme string - - // The type of the security scheme. Must be 'http'. - Type string -} - -// Defines configuration details for the OAuth 2.0 Implicit flow. -type ImplicitOAuthFlow struct { - // The authorization URL to be used for this flow. This MUST be a URL. - AuthzURL string - - // The URL to be used for obtaining refresh tokens. This MUST be a URL. - RefreshURL *string - - // The available scopes for the OAuth2 security scheme. A map between the scope - // name and a short description for it. - Scopes map[string]string } -// An error indicating an internal error on the server. -type InternalError struct { - // The error code for an internal server error. - Code int - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data any - - // The error message. - Message string -} +// Defines parameters for querying a task, with an option to limit history length. +type TaskQueryParams struct { + // The number of most recent messages from the task's history to retrieve. + HistoryLength *int -// Defines parameters for listing all push notification configurations associated -// with a task. -type ListTaskPushNotificationConfigParams struct { // The unique identifier of the task. - ID string + ID TaskID // Optional metadata associated with the request. Metadata map[string]any } -// Represents a request for the `tasks/pushNotificationConfig/list` -// method. -type ListTaskPushNotificationConfigRequest struct { - // The parameters identifying the task whose configurations are to be listed. - Params ListTaskPushNotificationConfigParams -} - -// Represents a response for the `tasks/pushNotificationConfig/list` method. -type ListTaskPushNotificationConfigResponse struct { - // The result, containing an array of all push notification configurations for the - // task. - Result []TaskPushConfig -} - -// Represents a single message in the conversation between a user and an agent. -type Message struct { - // The context identifier for this message, used to group related interactions. - ContextID *string - - // The URIs of extensions that are relevant to this message. - Extensions []string - - // The type of this object, used as a discriminator. Always 'message' for a - // Message. - Kind string - - // A unique identifier for the message, typically a UUID, generated by the sender. - MessageID string - - // Optional metadata for extensions. The key is an extension-specific identifier. - Metadata map[string]any - - // An array of content parts that form the message body. A message can be - // composed of multiple parts of different types (e.g., text and files). - Parts []MessagePartsElem - - // A list of other task IDs that this message references for additional context. - ReferenceTasks []TaskID - - // Identifies the sender of the message. - // service. - Role MessageRole - - // The identifier of the task this message is part of. Can be omitted for the - // first message of a new task. - TaskID *TaskID -} -type MessagePartsElem interface{} - -type MessageRole string - -const ( - MessageRoleAgent MessageRole = "agent" - MessageRoleUser MessageRole = "user" -) - // Defines configuration options for a `message/send` or `message/stream` request. type MessageSendConfig struct { // A list of output MIME types the client is prepared to accept in the response. @@ -588,8 +313,7 @@ type MessageSendConfig struct { PushConfig *PushConfig } -// Defines the parameters for a request to send a message to an agent. This can be -// used +// Defines the parameters for a request to send a message to an agent. This can be used // to create a new task, continue an existing one, or restart a task. type MessageSendParams struct { // Optional configuration for the send request. @@ -601,323 +325,3 @@ type MessageSendParams struct { // Optional metadata for extensions. Metadata map[string]any } - -// Defines a security scheme using mTLS authentication. -type MutualTLSSecurityScheme struct { - // An optional description for the security scheme. - Description *string - - // The type of the security scheme. Must be 'mutualTLS'. - Type string -} - -// Defines a security scheme using OAuth 2.0. -type OAuth2SecurityScheme struct { - // An optional description for the security scheme. - Description *string - - // An object containing configuration information for the supported OAuth 2.0 - // flows. - Flows OAuthFlows - - // URL to the oauth2 authorization server metadata - // [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414). TLS is required. - Oauth2MetadataURL *string - - // The type of the security scheme. Must be 'oauth2'. - Type string -} - -// Defines the configuration for the supported OAuth 2.0 flows. -type OAuthFlows struct { - // Configuration for the OAuth Authorization Code flow. Previously called - // accessCode in OpenAPI 2.0. - AuthzCode *AuthzCodeOAuthFlow - - // Configuration for the OAuth Client Credentials flow. Previously called - // application in OpenAPI 2.0. - ClientCredentials *ClientCredentialsOAuthFlow - - // Configuration for the OAuth Implicit flow. - Implicit *ImplicitOAuthFlow - - // Configuration for the OAuth Resource Owner Password flow. - Password *PasswordOAuthFlow -} - -// Defines a security scheme using OpenID Connect. -type OpenIDConnectSecurityScheme struct { - // An optional description for the security scheme. - Description *string - - // The OpenID Connect Discovery URL for the OIDC provider's metadata. - OpenIDConnectURL string - - // The type of the security scheme. Must be 'openIDConnect'. - Type string -} - -// A discriminated union representing a part of a message or artifact, which can -// be text, a file, or structured data. -type Part interface{} - -// Defines base properties common to all message or artifact parts. -type PartBase struct { - // Optional metadata associated with this part. - Metadata map[string]any -} - -// Defines configuration details for the OAuth 2.0 Resource Owner Password flow. -type PasswordOAuthFlow struct { - // The URL to be used for obtaining refresh tokens. This MUST be a URL. - RefreshURL *string - - // The available scopes for the OAuth2 security scheme. A map between the scope - // name and a short description for it. - Scopes map[string]string - - // The token URL to be used for this flow. This MUST be a URL. - TokenURL string -} - -// Defines authentication details for a push notification endpoint. -type PushAuthInfo struct { - // Optional credentials required by the push notification endpoint. - Credentials *string - - // A list of supported authentication schemes (e.g., 'Basic', 'Bearer'). - Schemes []string -} - -// Defines the configuration for setting up push notifications for task updates. -type PushConfig struct { - // Optional authentication details for the agent to use when calling the - // notification URL. - Auth *PushAuthInfo - - // A unique ID for the push notification configuration, set by the client - // to support multiple notification callbacks. - ID *string - - // A unique token for this task or session to validate incoming push - // notifications. - Token *string - - // The callback URL where the agent should send push notifications. - URL string -} - -// Defines a security scheme that can be used to secure an agent's endpoints. -// This is a discriminated union type based on the OpenAPI 3.0 Security Scheme -// Object. -type SecurityScheme interface{} - -// Defines base properties shared by all security scheme objects. -type SecuritySchemeBase struct { - // An optional description for the security scheme. - Description *string -} - -// Represents a request for the `message/send` method. -type SendMessageRequest struct { - // The parameters for sending a message. - Params MessageSendParams -} - -// Represents a response for the `message/send` method. -type SendMessageResponse interface { - isSendMessageResponse() -} - -func (Task) isSendMessageResponse() {} -func (Message) isSendMessageResponse() {} - -// Represents a request for the `message/stream` method. -type SendStreamingMessageRequest struct { - // The parameters for sending a message. - Params MessageSendParams -} - -// Represents a request for the `tasks/pushNotificationConfig/set` method. -type SetTaskPushNotificationConfigParams struct { - // The parameters for setting the push notification configuration. - Params TaskPushConfig -} - -// Represents a response for the `tasks/pushNotificationConfig/set` method. -type SetTaskPushNotificationConfigResponse struct { - // The result, containing the configured push notification settings. - Result TaskPushConfig -} - -type TaskID string - -// Represents a single, stateful operation or conversation between a client and an -// agent. -type Task struct { - // A collection of artifacts generated by the agent during the execution of the - // task. - Artifacts []Artifact - - // A server-generated identifier for maintaining context across multiple related - // tasks or interactions. - ContextID string - - // An array of messages exchanged during the task, representing the conversation - // history. - History []Message - - // A unique identifier for the task, generated by the server for a new task. - ID TaskID - - // The type of this object, used as a discriminator. Always 'task' for a Task. - Kind string - - // Optional metadata for extensions. The key is an extension-specific identifier. - Metadata map[string]any - - // The current status of the task, including its state and a descriptive message. - Status TaskStatus -} - -// An event sent by the agent to notify the client that an artifact has been -// generated or updated. This is typically used in streaming models. -type TaskArtifactUpdateEvent struct { - // If true, the content of this artifact should be appended to a previously sent - // artifact with the same ID. - Append *bool - - // The artifact that was generated or updated. - Artifact Artifact - - // The context ID associated with the task. - ContextID string - - // The type of this event, used as a discriminator. Always 'artifact-update'. - Kind string - - // If true, this is the final chunk of the artifact. - LastChunk *bool - - // Optional metadata for extensions. - Metadata map[string]any - - // The ID of the task this artifact belongs to. - TaskID TaskID -} - -// Defines parameters containing a task ID, used for simple task operations. -type TaskIDParams struct { - // The unique identifier of the task. - ID TaskID - - // Optional metadata associated with the request. - Metadata map[string]any -} - -// A container associating a push notification configuration with a specific task. -type TaskPushConfig struct { - // The push notification configuration for this task. - PushConfig PushConfig - - // The ID of the task. - TaskID TaskID -} - -// Defines parameters for querying a task, with an option to limit history length. -type TaskQueryParams struct { - // The number of most recent messages from the task's history to retrieve. - HistoryLength *int - - // The unique identifier of the task. - ID TaskID - - // Optional metadata associated with the request. - Metadata map[string]any -} - -// Represents a request for the `tasks/resubscribe` method, used to resume -// a streaming connection. -type TaskResubscriptionRequest struct { - // The parameters identifying the task to resubscribe to. - Params TaskIDParams -} - -type TaskState string - -const ( - TaskStateAuthRequired TaskState = "auth-required" - TaskStateCanceled TaskState = "canceled" - TaskStateCompleted TaskState = "completed" - TaskStateFailed TaskState = "failed" - TaskStateInputRequired TaskState = "input-required" - TaskStateRejected TaskState = "rejected" - TaskStateSubmitted TaskState = "submitted" - TaskStateUnknown TaskState = "unknown" - TaskStateWorking TaskState = "working" -) - -// Represents the status of a task at a specific point in time. -type TaskStatus struct { - // An optional, human-readable message providing more details about the current - // status. - Message *Message - - // The current state of the task's lifecycle. - State TaskState - - // An ISO 8601 datetime string indicating when this status was recorded. - Timestamp *string -} - -// Event interface is used to represent types that can be sent over a streaming connection. -type Event interface { - isEvent() -} - -func (t Task) isEvent() {} -func (t Message) isEvent() {} -func (t TaskStatusUpdateEvent) isEvent() {} -func (t TaskArtifactUpdateEvent) isEvent() {} - -// An event sent by the agent to notify the client of a change in a task's status. -// This is typically used in streaming or subscription models. -type TaskStatusUpdateEvent struct { - // The context ID associated with the task. - ContextID string - - // If true, this is the final event in the stream for this interaction. - Final bool - - // The type of this event, used as a discriminator. Always 'status-update'. - Kind string - - // Optional metadata for extensions. - Metadata map[string]any - - // The new status of the task. - Status TaskStatus - - // The ID of the task that was updated. - TaskID TaskID -} - -// Represents a text segment within a message or artifact. -type TextPart struct { - // The type of this part, used as a discriminator. Always 'text'. - Kind string - - // Optional metadata associated with this part. - Metadata map[string]any - - // The string content of the text part. - Text string -} - -type TransportProtocol string - -const ( - TransportProtocolJSONRPC TransportProtocol = "JSONRPC" - TransportProtocolGRPC TransportProtocol = "GRPC" - TransportProtocolHTTPJSON TransportProtocol = "HTTP+JSON" -) diff --git a/a2asrv/handler.go b/a2asrv/handler.go index ecce66a7..592a9964 100644 --- a/a2asrv/handler.go +++ b/a2asrv/handler.go @@ -10,19 +10,19 @@ import ( type RequestHandler interface { OnHandleGetTask(ctx context.Context, query a2a.TaskQueryParams) (a2a.Task, error) - OnHandleCancelTask(ctx context.Context, id a2a.TaskIDParams) (a2a.CancelTaskResponse, error) + OnHandleCancelTask(ctx context.Context, id a2a.TaskIDParams) (a2a.Task, error) - OnHandleSendMessage(ctx context.Context, message a2a.MessageSendParams) (a2a.SendMessageResponse, error) + OnHandleSendMessage(ctx context.Context, message a2a.MessageSendParams) (a2a.SendMessageResult, error) OnHandleResubscribeToTask(ctx context.Context, id a2a.TaskIDParams) iter.Seq2[a2a.Event, error] OnHandleSendMessageStream(ctx context.Context, message a2a.MessageSendParams) iter.Seq2[a2a.Event, error] - OnHandleGetTaskPushConfig(ctx context.Context, params a2a.GetTaskPushNotificationConfigParams) (a2a.GetTaskPushNotificationConfigResponse, error) + OnHandleGetTaskPushConfig(ctx context.Context, params a2a.GetTaskPushConfigParams) (a2a.TaskPushConfig, error) - OnHandleListTaskPushConfig(ctx context.Context, params a2a.ListTaskPushNotificationConfigParams) (a2a.ListTaskPushNotificationConfigResponse, error) + OnHandleListTaskPushConfig(ctx context.Context, params a2a.ListTaskPushConfigParams) ([]a2a.TaskPushConfig, error) - OnHandleSetTaskPushConfig(ctx context.Context, params a2a.SetTaskPushNotificationConfigParams) (a2a.SetTaskPushNotificationConfigResponse, error) + OnHandleSetTaskPushConfig(ctx context.Context, params a2a.SetTaskPushConfigParams) (a2a.SetTaskPushConfigResult, error) - OnHandleDeleteTaskPushConfig(ctx context.Context, params a2a.DeleteTaskPushNotificationConfigParams) (a2a.DeleteTaskPushNotificationConfigResponse, error) + OnHandleDeleteTaskPushConfig(ctx context.Context, params a2a.DeleteTaskPushConfigParams) error } From 0575127086dcffeea203bc6a2d6cc60f48cda6f9 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Wed, 6 Aug 2025 19:00:42 +0000 Subject: [PATCH 08/23] removed accidentally committed artifact --- internal/jsonrpc/spec.go | 3384 -------------------------------------- 1 file changed, 3384 deletions(-) delete mode 100644 internal/jsonrpc/spec.go diff --git a/internal/jsonrpc/spec.go b/internal/jsonrpc/spec.go deleted file mode 100644 index b1113076..00000000 --- a/internal/jsonrpc/spec.go +++ /dev/null @@ -1,3384 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package jsonrpc - -import "encoding/json" -import "errors" -import "fmt" -import "reflect" - -// A discriminated union of all standard JSON-RPC and A2A-specific error types. -type A2AError interface{} - -// A discriminated union representing all possible JSON-RPC 2.0 requests supported -// by the A2A specification. -type A2ARequest interface{} - -// Defines a security scheme using an API key. -type APIKeySecurityScheme struct { - // An optional description for the security scheme. - Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` - - // The location of the API key. - In APIKeySecuritySchemeIn `json:"in" yaml:"in" mapstructure:"in"` - - // The name of the header, query, or cookie parameter to be used. - Name string `json:"name" yaml:"name" mapstructure:"name"` - - // The type of the security scheme. Must be 'apiKey'. - Type string `json:"type" yaml:"type" mapstructure:"type"` -} - -type APIKeySecuritySchemeIn string - -const APIKeySecuritySchemeInCookie APIKeySecuritySchemeIn = "cookie" -const APIKeySecuritySchemeInHeader APIKeySecuritySchemeIn = "header" -const APIKeySecuritySchemeInQuery APIKeySecuritySchemeIn = "query" - -var enumValues_APIKeySecuritySchemeIn = []interface{}{ - "cookie", - "header", - "query", -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *APIKeySecuritySchemeIn) UnmarshalJSON(value []byte) error { - var v string - if err := json.Unmarshal(value, &v); err != nil { - return err - } - var ok bool - for _, expected := range enumValues_APIKeySecuritySchemeIn { - if reflect.DeepEqual(v, expected) { - ok = true - break - } - } - if !ok { - return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_APIKeySecuritySchemeIn, v) - } - *j = APIKeySecuritySchemeIn(v) - return nil -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *APIKeySecurityScheme) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["in"]; raw != nil && !ok { - return fmt.Errorf("field in in APIKeySecurityScheme: required") - } - if _, ok := raw["name"]; raw != nil && !ok { - return fmt.Errorf("field name in APIKeySecurityScheme: required") - } - if _, ok := raw["type"]; raw != nil && !ok { - return fmt.Errorf("field type in APIKeySecurityScheme: required") - } - type Plain APIKeySecurityScheme - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = APIKeySecurityScheme(plain) - return nil -} - -// Defines optional capabilities supported by an agent. -type AgentCapabilities struct { - // A list of protocol extensions supported by the agent. - Extensions []AgentExtension `json:"extensions,omitempty" yaml:"extensions,omitempty" mapstructure:"extensions,omitempty"` - - // Indicates if the agent supports sending push notifications for asynchronous - // task updates. - PushNotifications *bool `json:"pushNotifications,omitempty" yaml:"pushNotifications,omitempty" mapstructure:"pushNotifications,omitempty"` - - // Indicates if the agent provides a history of state transitions for a task. - StateTransitionHistory *bool `json:"stateTransitionHistory,omitempty" yaml:"stateTransitionHistory,omitempty" mapstructure:"stateTransitionHistory,omitempty"` - - // Indicates if the agent supports Server-Sent Events (SSE) for streaming - // responses. - Streaming *bool `json:"streaming,omitempty" yaml:"streaming,omitempty" mapstructure:"streaming,omitempty"` -} - -// The AgentCard is a self-describing manifest for an agent. It provides essential -// metadata including the agent's identity, capabilities, skills, supported -// communication methods, and security requirements. -type AgentCard struct { - // A list of additional supported interfaces (transport and URL combinations). - // This allows agents to expose multiple transports, potentially at different - // URLs. - // - // Best practices: - // - SHOULD include all supported transports for completeness - // - SHOULD include an entry matching the main 'url' and 'preferredTransport' - // - MAY reuse URLs if multiple transports are available at the same endpoint - // - MUST accurately declare the transport available at each URL - // - // Clients can select any interface from this list based on their transport - // capabilities - // and preferences. This enables transport negotiation and fallback scenarios. - AdditionalInterfaces []AgentInterface `json:"additionalInterfaces,omitempty" yaml:"additionalInterfaces,omitempty" mapstructure:"additionalInterfaces,omitempty"` - - // A declaration of optional capabilities supported by the agent. - Capabilities AgentCapabilities `json:"capabilities" yaml:"capabilities" mapstructure:"capabilities"` - - // Default set of supported input MIME types for all skills, which can be - // overridden on a per-skill basis. - DefaultInputModes []string `json:"defaultInputModes" yaml:"defaultInputModes" mapstructure:"defaultInputModes"` - - // Default set of supported output MIME types for all skills, which can be - // overridden on a per-skill basis. - DefaultOutputModes []string `json:"defaultOutputModes" yaml:"defaultOutputModes" mapstructure:"defaultOutputModes"` - - // A human-readable description of the agent, assisting users and other agents - // in understanding its purpose. - Description string `json:"description" yaml:"description" mapstructure:"description"` - - // An optional URL to the agent's documentation. - DocumentationUrl *string `json:"documentationUrl,omitempty" yaml:"documentationUrl,omitempty" mapstructure:"documentationUrl,omitempty"` - - // An optional URL to an icon for the agent. - IconUrl *string `json:"iconUrl,omitempty" yaml:"iconUrl,omitempty" mapstructure:"iconUrl,omitempty"` - - // A human-readable name for the agent. - Name string `json:"name" yaml:"name" mapstructure:"name"` - - // The transport protocol for the preferred endpoint (the main 'url' field). - // If not specified, defaults to 'JSONRPC'. - // - // IMPORTANT: The transport specified here MUST be available at the main 'url'. - // This creates a binding between the main URL and its supported transport - // protocol. - // Clients should prefer this transport and URL combination when both are - // supported. - PreferredTransport string `json:"preferredTransport,omitempty" yaml:"preferredTransport,omitempty" mapstructure:"preferredTransport,omitempty"` - - // The version of the A2A protocol this agent supports. - ProtocolVersion string `json:"protocolVersion" yaml:"protocolVersion" mapstructure:"protocolVersion"` - - // Information about the agent's service provider. - Provider *AgentProvider `json:"provider,omitempty" yaml:"provider,omitempty" mapstructure:"provider,omitempty"` - - // A list of security requirement objects that apply to all agent interactions. - // Each object - // lists security schemes that can be used. Follows the OpenAPI 3.0 Security - // Requirement Object. - // This list can be seen as an OR of ANDs. Each object in the list describes one - // possible - // set of security requirements that must be present on a request. This allows - // specifying, - // for example, "callers must either use OAuth OR an API Key AND mTLS." - Security []map[string][]string `json:"security,omitempty" yaml:"security,omitempty" mapstructure:"security,omitempty"` - - // A declaration of the security schemes available to authorize requests. The key - // is the - // scheme name. Follows the OpenAPI 3.0 Security Scheme Object. - SecuritySchemes map[string]interface{} `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty" mapstructure:"securitySchemes,omitempty"` - - // JSON Web Signatures computed for this AgentCard. - Signatures []AgentCardSignature `json:"signatures,omitempty" yaml:"signatures,omitempty" mapstructure:"signatures,omitempty"` - - // The set of skills, or distinct capabilities, that the agent can perform. - Skills []AgentSkill `json:"skills" yaml:"skills" mapstructure:"skills"` - - // If true, the agent can provide an extended agent card with additional details - // to authenticated users. Defaults to false. - SupportsAuthenticatedExtendedCard *bool `json:"supportsAuthenticatedExtendedCard,omitempty" yaml:"supportsAuthenticatedExtendedCard,omitempty" mapstructure:"supportsAuthenticatedExtendedCard,omitempty"` - - // The preferred endpoint URL for interacting with the agent. - // This URL MUST support the transport specified by 'preferredTransport'. - Url string `json:"url" yaml:"url" mapstructure:"url"` - - // The agent's own version number. The format is defined by the provider. - Version string `json:"version" yaml:"version" mapstructure:"version"` -} - -// AgentCardSignature represents a JWS signature of an AgentCard. -// This follows the JSON format of an RFC 7515 JSON Web Signature (JWS). -type AgentCardSignature struct { - // The unprotected JWS header values. - Header map[string]interface{} `json:"header,omitempty" yaml:"header,omitempty" mapstructure:"header,omitempty"` - - // The protected JWS header for the signature. This is a Base64url-encoded - // JSON object, as per RFC 7515. - Protected string `json:"protected" yaml:"protected" mapstructure:"protected"` - - // The computed signature, Base64url-encoded. - Signature string `json:"signature" yaml:"signature" mapstructure:"signature"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *AgentCardSignature) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["protected"]; raw != nil && !ok { - return fmt.Errorf("field protected in AgentCardSignature: required") - } - if _, ok := raw["signature"]; raw != nil && !ok { - return fmt.Errorf("field signature in AgentCardSignature: required") - } - type Plain AgentCardSignature - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = AgentCardSignature(plain) - return nil -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *AgentCard) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["capabilities"]; raw != nil && !ok { - return fmt.Errorf("field capabilities in AgentCard: required") - } - if _, ok := raw["defaultInputModes"]; raw != nil && !ok { - return fmt.Errorf("field defaultInputModes in AgentCard: required") - } - if _, ok := raw["defaultOutputModes"]; raw != nil && !ok { - return fmt.Errorf("field defaultOutputModes in AgentCard: required") - } - if _, ok := raw["description"]; raw != nil && !ok { - return fmt.Errorf("field description in AgentCard: required") - } - if _, ok := raw["name"]; raw != nil && !ok { - return fmt.Errorf("field name in AgentCard: required") - } - if _, ok := raw["skills"]; raw != nil && !ok { - return fmt.Errorf("field skills in AgentCard: required") - } - if _, ok := raw["url"]; raw != nil && !ok { - return fmt.Errorf("field url in AgentCard: required") - } - if _, ok := raw["version"]; raw != nil && !ok { - return fmt.Errorf("field version in AgentCard: required") - } - type Plain AgentCard - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - if v, ok := raw["preferredTransport"]; !ok || v == nil { - plain.PreferredTransport = "JSONRPC" - } - if v, ok := raw["protocolVersion"]; !ok || v == nil { - plain.ProtocolVersion = "0.3.0" - } - *j = AgentCard(plain) - return nil -} - -// A declaration of a protocol extension supported by an Agent. -type AgentExtension struct { - // A human-readable description of how this agent uses the extension. - Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` - - // Optional, extension-specific configuration parameters. - Params map[string]interface{} `json:"params,omitempty" yaml:"params,omitempty" mapstructure:"params,omitempty"` - - // If true, the client must understand and comply with the extension's - // requirements - // to interact with the agent. - Required *bool `json:"required,omitempty" yaml:"required,omitempty" mapstructure:"required,omitempty"` - - // The unique URI identifying the extension. - Uri string `json:"uri" yaml:"uri" mapstructure:"uri"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *AgentExtension) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["uri"]; raw != nil && !ok { - return fmt.Errorf("field uri in AgentExtension: required") - } - type Plain AgentExtension - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = AgentExtension(plain) - return nil -} - -// Declares a combination of a target URL and a transport protocol for interacting -// with the agent. -// This allows agents to expose the same functionality over multiple transport -// mechanisms. -type AgentInterface struct { - // The transport protocol supported at this URL. - Transport string `json:"transport" yaml:"transport" mapstructure:"transport"` - - // The URL where this interface is available. Must be a valid absolute HTTPS URL - // in production. - Url string `json:"url" yaml:"url" mapstructure:"url"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *AgentInterface) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["transport"]; raw != nil && !ok { - return fmt.Errorf("field transport in AgentInterface: required") - } - if _, ok := raw["url"]; raw != nil && !ok { - return fmt.Errorf("field url in AgentInterface: required") - } - type Plain AgentInterface - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = AgentInterface(plain) - return nil -} - -// Represents the service provider of an agent. -type AgentProvider struct { - // The name of the agent provider's organization. - Organization string `json:"organization" yaml:"organization" mapstructure:"organization"` - - // A URL for the agent provider's website or relevant documentation. - Url string `json:"url" yaml:"url" mapstructure:"url"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *AgentProvider) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["organization"]; raw != nil && !ok { - return fmt.Errorf("field organization in AgentProvider: required") - } - if _, ok := raw["url"]; raw != nil && !ok { - return fmt.Errorf("field url in AgentProvider: required") - } - type Plain AgentProvider - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = AgentProvider(plain) - return nil -} - -// Represents a distinct capability or function that an agent can perform. -type AgentSkill struct { - // A detailed description of the skill, intended to help clients or users - // understand its purpose and functionality. - Description string `json:"description" yaml:"description" mapstructure:"description"` - - // Example prompts or scenarios that this skill can handle. Provides a hint to - // the client on how to use the skill. - Examples []string `json:"examples,omitempty" yaml:"examples,omitempty" mapstructure:"examples,omitempty"` - - // A unique identifier for the agent's skill. - Id string `json:"id" yaml:"id" mapstructure:"id"` - - // The set of supported input MIME types for this skill, overriding the agent's - // defaults. - InputModes []string `json:"inputModes,omitempty" yaml:"inputModes,omitempty" mapstructure:"inputModes,omitempty"` - - // A human-readable name for the skill. - Name string `json:"name" yaml:"name" mapstructure:"name"` - - // The set of supported output MIME types for this skill, overriding the agent's - // defaults. - OutputModes []string `json:"outputModes,omitempty" yaml:"outputModes,omitempty" mapstructure:"outputModes,omitempty"` - - // Security schemes necessary for the agent to leverage this skill. - // As in the overall AgentCard.security, this list represents a logical OR of - // security - // requirement objects. Each object is a set of security schemes that must be used - // together - // (a logical AND). - Security []map[string][]string `json:"security,omitempty" yaml:"security,omitempty" mapstructure:"security,omitempty"` - - // A set of keywords describing the skill's capabilities. - Tags []string `json:"tags" yaml:"tags" mapstructure:"tags"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *AgentSkill) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["description"]; raw != nil && !ok { - return fmt.Errorf("field description in AgentSkill: required") - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in AgentSkill: required") - } - if _, ok := raw["name"]; raw != nil && !ok { - return fmt.Errorf("field name in AgentSkill: required") - } - if _, ok := raw["tags"]; raw != nil && !ok { - return fmt.Errorf("field tags in AgentSkill: required") - } - type Plain AgentSkill - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = AgentSkill(plain) - return nil -} - -// Represents a file, data structure, or other resource generated by an agent -// during a task. -type Artifact struct { - // A unique identifier for the artifact within the scope of the task. - ArtifactId string `json:"artifactId" yaml:"artifactId" mapstructure:"artifactId"` - - // An optional, human-readable description of the artifact. - Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` - - // The URIs of extensions that are relevant to this artifact. - Extensions []string `json:"extensions,omitempty" yaml:"extensions,omitempty" mapstructure:"extensions,omitempty"` - - // Optional metadata for extensions. The key is an extension-specific identifier. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` - - // An optional, human-readable name for the artifact. - Name *string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty"` - - // An array of content parts that make up the artifact. - Parts []ArtifactPartsElem `json:"parts" yaml:"parts" mapstructure:"parts"` -} - -type ArtifactPartsElem interface{} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *Artifact) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["artifactId"]; raw != nil && !ok { - return fmt.Errorf("field artifactId in Artifact: required") - } - if _, ok := raw["parts"]; raw != nil && !ok { - return fmt.Errorf("field parts in Artifact: required") - } - type Plain Artifact - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = Artifact(plain) - return nil -} - -// An A2A-specific error indicating that the agent does not have an Authenticated -// Extended Card configured -type AuthenticatedExtendedCardNotConfiguredError struct { - // The error code for when an authenticated extended card is not configured. - Code int `json:"code" yaml:"code" mapstructure:"code"` - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` - - // The error message. - Message string `json:"message" yaml:"message" mapstructure:"message"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *AuthenticatedExtendedCardNotConfiguredError) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["code"]; raw != nil && !ok { - return fmt.Errorf("field code in AuthenticatedExtendedCardNotConfiguredError: required") - } - type Plain AuthenticatedExtendedCardNotConfiguredError - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - if v, ok := raw["message"]; !ok || v == nil { - plain.Message = "Authenticated Extended Card is not configured" - } - *j = AuthenticatedExtendedCardNotConfiguredError(plain) - return nil -} - -// Defines configuration details for the OAuth 2.0 Authorization Code flow. -type AuthorizationCodeOAuthFlow struct { - // The authorization URL to be used for this flow. - // This MUST be a URL and use TLS. - AuthorizationUrl string `json:"authorizationUrl" yaml:"authorizationUrl" mapstructure:"authorizationUrl"` - - // The URL to be used for obtaining refresh tokens. - // This MUST be a URL and use TLS. - RefreshUrl *string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty" mapstructure:"refreshUrl,omitempty"` - - // The available scopes for the OAuth2 security scheme. A map between the scope - // name and a short description for it. - Scopes map[string]string `json:"scopes" yaml:"scopes" mapstructure:"scopes"` - - // The token URL to be used for this flow. - // This MUST be a URL and use TLS. - TokenUrl string `json:"tokenUrl" yaml:"tokenUrl" mapstructure:"tokenUrl"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *AuthorizationCodeOAuthFlow) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["authorizationUrl"]; raw != nil && !ok { - return fmt.Errorf("field authorizationUrl in AuthorizationCodeOAuthFlow: required") - } - if _, ok := raw["scopes"]; raw != nil && !ok { - return fmt.Errorf("field scopes in AuthorizationCodeOAuthFlow: required") - } - if _, ok := raw["tokenUrl"]; raw != nil && !ok { - return fmt.Errorf("field tokenUrl in AuthorizationCodeOAuthFlow: required") - } - type Plain AuthorizationCodeOAuthFlow - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = AuthorizationCodeOAuthFlow(plain) - return nil -} - -// Represents a JSON-RPC request for the `tasks/cancel` method. -type CancelTaskRequest struct { - // The identifier for this request. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The method name. Must be 'tasks/cancel'. - Method string `json:"method" yaml:"method" mapstructure:"method"` - - // The parameters identifying the task to cancel. - Params TaskIdParams `json:"params" yaml:"params" mapstructure:"params"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *CancelTaskRequest) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in CancelTaskRequest: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in CancelTaskRequest: required") - } - if _, ok := raw["method"]; raw != nil && !ok { - return fmt.Errorf("field method in CancelTaskRequest: required") - } - if _, ok := raw["params"]; raw != nil && !ok { - return fmt.Errorf("field params in CancelTaskRequest: required") - } - type Plain CancelTaskRequest - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = CancelTaskRequest(plain) - return nil -} - -// Represents a JSON-RPC response for the `tasks/cancel` method. -type CancelTaskResponse interface{} - -// Represents a successful JSON-RPC response for the `tasks/cancel` method. -type CancelTaskSuccessResponse struct { - // The identifier established by the client. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The result, containing the final state of the canceled Task object. - Result Task `json:"result" yaml:"result" mapstructure:"result"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *CancelTaskSuccessResponse) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in CancelTaskSuccessResponse: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in CancelTaskSuccessResponse: required") - } - if _, ok := raw["result"]; raw != nil && !ok { - return fmt.Errorf("field result in CancelTaskSuccessResponse: required") - } - type Plain CancelTaskSuccessResponse - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = CancelTaskSuccessResponse(plain) - return nil -} - -// Defines configuration details for the OAuth 2.0 Client Credentials flow. -type ClientCredentialsOAuthFlow struct { - // The URL to be used for obtaining refresh tokens. This MUST be a URL. - RefreshUrl *string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty" mapstructure:"refreshUrl,omitempty"` - - // The available scopes for the OAuth2 security scheme. A map between the scope - // name and a short description for it. - Scopes map[string]string `json:"scopes" yaml:"scopes" mapstructure:"scopes"` - - // The token URL to be used for this flow. This MUST be a URL. - TokenUrl string `json:"tokenUrl" yaml:"tokenUrl" mapstructure:"tokenUrl"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *ClientCredentialsOAuthFlow) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["scopes"]; raw != nil && !ok { - return fmt.Errorf("field scopes in ClientCredentialsOAuthFlow: required") - } - if _, ok := raw["tokenUrl"]; raw != nil && !ok { - return fmt.Errorf("field tokenUrl in ClientCredentialsOAuthFlow: required") - } - type Plain ClientCredentialsOAuthFlow - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = ClientCredentialsOAuthFlow(plain) - return nil -} - -// An A2A-specific error indicating an incompatibility between the requested -// content types and the agent's capabilities. -type ContentTypeNotSupportedError struct { - // The error code for an unsupported content type. - Code int `json:"code" yaml:"code" mapstructure:"code"` - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` - - // The error message. - Message string `json:"message" yaml:"message" mapstructure:"message"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *ContentTypeNotSupportedError) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["code"]; raw != nil && !ok { - return fmt.Errorf("field code in ContentTypeNotSupportedError: required") - } - type Plain ContentTypeNotSupportedError - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - if v, ok := raw["message"]; !ok || v == nil { - plain.Message = "Incompatible content types" - } - *j = ContentTypeNotSupportedError(plain) - return nil -} - -// Represents a structured data segment (e.g., JSON) within a message or artifact. -type DataPart struct { - // The structured data content. - Data map[string]interface{} `json:"data" yaml:"data" mapstructure:"data"` - - // The type of this part, used as a discriminator. Always 'data'. - Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` - - // Optional metadata associated with this part. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *DataPart) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["data"]; raw != nil && !ok { - return fmt.Errorf("field data in DataPart: required") - } - if _, ok := raw["kind"]; raw != nil && !ok { - return fmt.Errorf("field kind in DataPart: required") - } - type Plain DataPart - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = DataPart(plain) - return nil -} - -// Defines parameters for deleting a specific push notification configuration for a -// task. -type DeleteTaskPushNotificationConfigParams struct { - // The unique identifier of the task. - Id string `json:"id" yaml:"id" mapstructure:"id"` - - // Optional metadata associated with the request. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` - - // The ID of the push notification configuration to delete. - PushNotificationConfigId string `json:"pushNotificationConfigId" yaml:"pushNotificationConfigId" mapstructure:"pushNotificationConfigId"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *DeleteTaskPushNotificationConfigParams) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in DeleteTaskPushNotificationConfigParams: required") - } - if _, ok := raw["pushNotificationConfigId"]; raw != nil && !ok { - return fmt.Errorf("field pushNotificationConfigId in DeleteTaskPushNotificationConfigParams: required") - } - type Plain DeleteTaskPushNotificationConfigParams - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = DeleteTaskPushNotificationConfigParams(plain) - return nil -} - -// Represents a JSON-RPC request for the `tasks/pushNotificationConfig/delete` -// method. -type DeleteTaskPushNotificationConfigRequest struct { - // The identifier for this request. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The method name. Must be 'tasks/pushNotificationConfig/delete'. - Method string `json:"method" yaml:"method" mapstructure:"method"` - - // The parameters identifying the push notification configuration to delete. - Params DeleteTaskPushNotificationConfigParams `json:"params" yaml:"params" mapstructure:"params"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *DeleteTaskPushNotificationConfigRequest) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in DeleteTaskPushNotificationConfigRequest: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in DeleteTaskPushNotificationConfigRequest: required") - } - if _, ok := raw["method"]; raw != nil && !ok { - return fmt.Errorf("field method in DeleteTaskPushNotificationConfigRequest: required") - } - if _, ok := raw["params"]; raw != nil && !ok { - return fmt.Errorf("field params in DeleteTaskPushNotificationConfigRequest: required") - } - type Plain DeleteTaskPushNotificationConfigRequest - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = DeleteTaskPushNotificationConfigRequest(plain) - return nil -} - -// Represents a JSON-RPC response for the `tasks/pushNotificationConfig/delete` -// method. -type DeleteTaskPushNotificationConfigResponse interface{} - -// Represents a successful JSON-RPC response for the -// `tasks/pushNotificationConfig/delete` method. -type DeleteTaskPushNotificationConfigSuccessResponse struct { - // The identifier established by the client. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The result is null on successful deletion. - Result interface{} `json:"result" yaml:"result" mapstructure:"result"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *DeleteTaskPushNotificationConfigSuccessResponse) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in DeleteTaskPushNotificationConfigSuccessResponse: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in DeleteTaskPushNotificationConfigSuccessResponse: required") - } - if _, ok := raw["result"]; raw != nil && !ok { - return fmt.Errorf("field result in DeleteTaskPushNotificationConfigSuccessResponse: required") - } - type Plain DeleteTaskPushNotificationConfigSuccessResponse - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - if plain.Result != nil { - return fmt.Errorf("field %s: must be null", "result") - } - *j = DeleteTaskPushNotificationConfigSuccessResponse(plain) - return nil -} - -// Defines base properties for a file. -type FileBase struct { - // The MIME type of the file (e.g., "application/pdf"). - MimeType *string `json:"mimeType,omitempty" yaml:"mimeType,omitempty" mapstructure:"mimeType,omitempty"` - - // An optional name for the file (e.g., "document.pdf"). - Name *string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty"` -} - -// Represents a file segment within a message or artifact. The file content can be -// provided either directly as bytes or as a URI. -type FilePart struct { - // The file content, represented as either a URI or as base64-encoded bytes. - File FilePartFile `json:"file" yaml:"file" mapstructure:"file"` - - // The type of this part, used as a discriminator. Always 'file'. - Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` - - // Optional metadata associated with this part. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` -} - -// Represents a file with its content provided directly as a base64-encoded string. -type FilePartFile struct { - // The base64-encoded content of the file. - Bytes string `json:"bytes" yaml:"bytes" mapstructure:"bytes"` - - // The MIME type of the file (e.g., "application/pdf"). - MimeType *string `json:"mimeType,omitempty" yaml:"mimeType,omitempty" mapstructure:"mimeType,omitempty"` - - // An optional name for the file (e.g., "document.pdf"). - Name *string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty"` - - // A URL pointing to the file's content. - Uri string `json:"uri" yaml:"uri" mapstructure:"uri"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *FilePartFile) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - var filePartFile_0 FilePartFile_0 - var filePartFile_1 FilePartFile_1 - var errs []error - if err := filePartFile_0.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := filePartFile_1.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if len(errs) == 2 { - return fmt.Errorf("all validators failed: %s", errors.Join(errs...)) - } - type Plain FilePartFile - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = FilePartFile(plain) - return nil -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *FilePart) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["file"]; raw != nil && !ok { - return fmt.Errorf("field file in FilePart: required") - } - if _, ok := raw["kind"]; raw != nil && !ok { - return fmt.Errorf("field kind in FilePart: required") - } - type Plain FilePart - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = FilePart(plain) - return nil -} - -// Represents a file with its content provided directly as a base64-encoded string. -type FileWithBytes struct { - // The base64-encoded content of the file. - Bytes string `json:"bytes" yaml:"bytes" mapstructure:"bytes"` - - // The MIME type of the file (e.g., "application/pdf"). - MimeType *string `json:"mimeType,omitempty" yaml:"mimeType,omitempty" mapstructure:"mimeType,omitempty"` - - // An optional name for the file (e.g., "document.pdf"). - Name *string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *FileWithBytes) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["bytes"]; raw != nil && !ok { - return fmt.Errorf("field bytes in FileWithBytes: required") - } - type Plain FileWithBytes - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = FileWithBytes(plain) - return nil -} - -// Represents a file with its content located at a specific URI. -type FileWithUri struct { - // The MIME type of the file (e.g., "application/pdf"). - MimeType *string `json:"mimeType,omitempty" yaml:"mimeType,omitempty" mapstructure:"mimeType,omitempty"` - - // An optional name for the file (e.g., "document.pdf"). - Name *string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty"` - - // A URL pointing to the file's content. - Uri string `json:"uri" yaml:"uri" mapstructure:"uri"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *FileWithUri) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["uri"]; raw != nil && !ok { - return fmt.Errorf("field uri in FileWithUri: required") - } - type Plain FileWithUri - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = FileWithUri(plain) - return nil -} - -// Represents a JSON-RPC request for the `agent/getAuthenticatedExtendedCard` -// method. -type GetAuthenticatedExtendedCardRequest struct { - // The identifier for this request. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The method name. Must be 'agent/getAuthenticatedExtendedCard'. - Method string `json:"method" yaml:"method" mapstructure:"method"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *GetAuthenticatedExtendedCardRequest) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in GetAuthenticatedExtendedCardRequest: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in GetAuthenticatedExtendedCardRequest: required") - } - if _, ok := raw["method"]; raw != nil && !ok { - return fmt.Errorf("field method in GetAuthenticatedExtendedCardRequest: required") - } - type Plain GetAuthenticatedExtendedCardRequest - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = GetAuthenticatedExtendedCardRequest(plain) - return nil -} - -// Represents a JSON-RPC response for the `agent/getAuthenticatedExtendedCard` -// method. -type GetAuthenticatedExtendedCardResponse interface{} - -// Represents a successful JSON-RPC response for the -// `agent/getAuthenticatedExtendedCard` method. -type GetAuthenticatedExtendedCardSuccessResponse struct { - // The identifier established by the client. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The result is an Agent Card object. - Result AgentCard `json:"result" yaml:"result" mapstructure:"result"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *GetAuthenticatedExtendedCardSuccessResponse) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in GetAuthenticatedExtendedCardSuccessResponse: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in GetAuthenticatedExtendedCardSuccessResponse: required") - } - if _, ok := raw["result"]; raw != nil && !ok { - return fmt.Errorf("field result in GetAuthenticatedExtendedCardSuccessResponse: required") - } - type Plain GetAuthenticatedExtendedCardSuccessResponse - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = GetAuthenticatedExtendedCardSuccessResponse(plain) - return nil -} - -// Defines parameters for fetching a specific push notification configuration for a -// task. -type GetTaskPushNotificationConfigParams struct { - // The unique identifier of the task. - Id string `json:"id" yaml:"id" mapstructure:"id"` - - // Optional metadata associated with the request. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` - - // The ID of the push notification configuration to retrieve. - PushNotificationConfigId *string `json:"pushNotificationConfigId,omitempty" yaml:"pushNotificationConfigId,omitempty" mapstructure:"pushNotificationConfigId,omitempty"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *GetTaskPushNotificationConfigParams) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in GetTaskPushNotificationConfigParams: required") - } - type Plain GetTaskPushNotificationConfigParams - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = GetTaskPushNotificationConfigParams(plain) - return nil -} - -// Represents a JSON-RPC request for the `tasks/pushNotificationConfig/get` method. -type GetTaskPushNotificationConfigRequest struct { - // The identifier for this request. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The method name. Must be 'tasks/pushNotificationConfig/get'. - Method string `json:"method" yaml:"method" mapstructure:"method"` - - // The parameters for getting a push notification configuration. - Params GetTaskPushNotificationConfigRequestParams `json:"params" yaml:"params" mapstructure:"params"` -} - -// Defines parameters containing a task ID, used for simple task operations. -type GetTaskPushNotificationConfigRequestParams struct { - // The unique identifier of the task. - Id string `json:"id" yaml:"id" mapstructure:"id"` - - // Optional metadata associated with the request. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` - - // The ID of the push notification configuration to retrieve. - PushNotificationConfigId *string `json:"pushNotificationConfigId,omitempty" yaml:"pushNotificationConfigId,omitempty" mapstructure:"pushNotificationConfigId,omitempty"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *GetTaskPushNotificationConfigRequestParams) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - var getTaskPushNotificationConfigRequestParams_0 GetTaskPushNotificationConfigRequestParams_0 - var getTaskPushNotificationConfigRequestParams_1 GetTaskPushNotificationConfigRequestParams_1 - var errs []error - if err := getTaskPushNotificationConfigRequestParams_0.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := getTaskPushNotificationConfigRequestParams_1.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if len(errs) == 2 { - return fmt.Errorf("all validators failed: %s", errors.Join(errs...)) - } - type Plain GetTaskPushNotificationConfigRequestParams - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = GetTaskPushNotificationConfigRequestParams(plain) - return nil -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *GetTaskPushNotificationConfigRequest) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in GetTaskPushNotificationConfigRequest: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in GetTaskPushNotificationConfigRequest: required") - } - if _, ok := raw["method"]; raw != nil && !ok { - return fmt.Errorf("field method in GetTaskPushNotificationConfigRequest: required") - } - if _, ok := raw["params"]; raw != nil && !ok { - return fmt.Errorf("field params in GetTaskPushNotificationConfigRequest: required") - } - type Plain GetTaskPushNotificationConfigRequest - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = GetTaskPushNotificationConfigRequest(plain) - return nil -} - -// Represents a JSON-RPC response for the `tasks/pushNotificationConfig/get` -// method. -type GetTaskPushNotificationConfigResponse interface{} - -// Represents a successful JSON-RPC response for the -// `tasks/pushNotificationConfig/get` method. -type GetTaskPushNotificationConfigSuccessResponse struct { - // The identifier established by the client. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The result, containing the requested push notification configuration. - Result TaskPushNotificationConfig `json:"result" yaml:"result" mapstructure:"result"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *GetTaskPushNotificationConfigSuccessResponse) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in GetTaskPushNotificationConfigSuccessResponse: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in GetTaskPushNotificationConfigSuccessResponse: required") - } - if _, ok := raw["result"]; raw != nil && !ok { - return fmt.Errorf("field result in GetTaskPushNotificationConfigSuccessResponse: required") - } - type Plain GetTaskPushNotificationConfigSuccessResponse - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = GetTaskPushNotificationConfigSuccessResponse(plain) - return nil -} - -// Represents a JSON-RPC request for the `tasks/get` method. -type GetTaskRequest struct { - // The identifier for this request. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The method name. Must be 'tasks/get'. - Method string `json:"method" yaml:"method" mapstructure:"method"` - - // The parameters for querying a task. - Params TaskQueryParams `json:"params" yaml:"params" mapstructure:"params"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *GetTaskRequest) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in GetTaskRequest: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in GetTaskRequest: required") - } - if _, ok := raw["method"]; raw != nil && !ok { - return fmt.Errorf("field method in GetTaskRequest: required") - } - if _, ok := raw["params"]; raw != nil && !ok { - return fmt.Errorf("field params in GetTaskRequest: required") - } - type Plain GetTaskRequest - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = GetTaskRequest(plain) - return nil -} - -// Represents a JSON-RPC response for the `tasks/get` method. -type GetTaskResponse interface{} - -// Represents a successful JSON-RPC response for the `tasks/get` method. -type GetTaskSuccessResponse struct { - // The identifier established by the client. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The result, containing the requested Task object. - Result Task `json:"result" yaml:"result" mapstructure:"result"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *GetTaskSuccessResponse) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in GetTaskSuccessResponse: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in GetTaskSuccessResponse: required") - } - if _, ok := raw["result"]; raw != nil && !ok { - return fmt.Errorf("field result in GetTaskSuccessResponse: required") - } - type Plain GetTaskSuccessResponse - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = GetTaskSuccessResponse(plain) - return nil -} - -// Defines a security scheme using HTTP authentication. -type HTTPAuthSecurityScheme struct { - // A hint to the client to identify how the bearer token is formatted (e.g., - // "JWT"). - // This is primarily for documentation purposes. - BearerFormat *string `json:"bearerFormat,omitempty" yaml:"bearerFormat,omitempty" mapstructure:"bearerFormat,omitempty"` - - // An optional description for the security scheme. - Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` - - // The name of the HTTP Authentication scheme to be used in the Authorization - // header, - // as defined in RFC7235 (e.g., "Bearer"). - // This value should be registered in the IANA Authentication Scheme registry. - Scheme string `json:"scheme" yaml:"scheme" mapstructure:"scheme"` - - // The type of the security scheme. Must be 'http'. - Type string `json:"type" yaml:"type" mapstructure:"type"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *HTTPAuthSecurityScheme) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["scheme"]; raw != nil && !ok { - return fmt.Errorf("field scheme in HTTPAuthSecurityScheme: required") - } - if _, ok := raw["type"]; raw != nil && !ok { - return fmt.Errorf("field type in HTTPAuthSecurityScheme: required") - } - type Plain HTTPAuthSecurityScheme - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = HTTPAuthSecurityScheme(plain) - return nil -} - -// Defines configuration details for the OAuth 2.0 Implicit flow. -type ImplicitOAuthFlow struct { - // The authorization URL to be used for this flow. This MUST be a URL. - AuthorizationUrl string `json:"authorizationUrl" yaml:"authorizationUrl" mapstructure:"authorizationUrl"` - - // The URL to be used for obtaining refresh tokens. This MUST be a URL. - RefreshUrl *string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty" mapstructure:"refreshUrl,omitempty"` - - // The available scopes for the OAuth2 security scheme. A map between the scope - // name and a short description for it. - Scopes map[string]string `json:"scopes" yaml:"scopes" mapstructure:"scopes"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *ImplicitOAuthFlow) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["authorizationUrl"]; raw != nil && !ok { - return fmt.Errorf("field authorizationUrl in ImplicitOAuthFlow: required") - } - if _, ok := raw["scopes"]; raw != nil && !ok { - return fmt.Errorf("field scopes in ImplicitOAuthFlow: required") - } - type Plain ImplicitOAuthFlow - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = ImplicitOAuthFlow(plain) - return nil -} - -// An error indicating an internal error on the server. -type InternalError struct { - // The error code for an internal server error. - Code int `json:"code" yaml:"code" mapstructure:"code"` - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` - - // The error message. - Message string `json:"message" yaml:"message" mapstructure:"message"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *InternalError) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["code"]; raw != nil && !ok { - return fmt.Errorf("field code in InternalError: required") - } - type Plain InternalError - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - if v, ok := raw["message"]; !ok || v == nil { - plain.Message = "Internal error" - } - *j = InternalError(plain) - return nil -} - -// An A2A-specific error indicating that the agent returned a response that -// does not conform to the specification for the current method. -type InvalidAgentResponseError struct { - // The error code for an invalid agent response. - Code int `json:"code" yaml:"code" mapstructure:"code"` - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` - - // The error message. - Message string `json:"message" yaml:"message" mapstructure:"message"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *InvalidAgentResponseError) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["code"]; raw != nil && !ok { - return fmt.Errorf("field code in InvalidAgentResponseError: required") - } - type Plain InvalidAgentResponseError - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - if v, ok := raw["message"]; !ok || v == nil { - plain.Message = "Invalid agent response" - } - *j = InvalidAgentResponseError(plain) - return nil -} - -// An error indicating that the method parameters are invalid. -type InvalidParamsError struct { - // The error code for an invalid parameters error. - Code int `json:"code" yaml:"code" mapstructure:"code"` - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` - - // The error message. - Message string `json:"message" yaml:"message" mapstructure:"message"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *InvalidParamsError) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["code"]; raw != nil && !ok { - return fmt.Errorf("field code in InvalidParamsError: required") - } - type Plain InvalidParamsError - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - if v, ok := raw["message"]; !ok || v == nil { - plain.Message = "Invalid parameters" - } - *j = InvalidParamsError(plain) - return nil -} - -// An error indicating that the JSON sent is not a valid Request object. -type InvalidRequestError struct { - // The error code for an invalid request. - Code int `json:"code" yaml:"code" mapstructure:"code"` - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` - - // The error message. - Message string `json:"message" yaml:"message" mapstructure:"message"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *InvalidRequestError) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["code"]; raw != nil && !ok { - return fmt.Errorf("field code in InvalidRequestError: required") - } - type Plain InvalidRequestError - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - if v, ok := raw["message"]; !ok || v == nil { - plain.Message = "Request payload validation error" - } - *j = InvalidRequestError(plain) - return nil -} - -// An error indicating that the server received invalid JSON. -type JSONParseError struct { - // The error code for a JSON parse error. - Code int `json:"code" yaml:"code" mapstructure:"code"` - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` - - // The error message. - Message string `json:"message" yaml:"message" mapstructure:"message"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *JSONParseError) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["code"]; raw != nil && !ok { - return fmt.Errorf("field code in JSONParseError: required") - } - type Plain JSONParseError - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - if v, ok := raw["message"]; !ok || v == nil { - plain.Message = "Invalid JSON payload" - } - *j = JSONParseError(plain) - return nil -} - -// Represents a JSON-RPC 2.0 Error object, included in an error response. -type JSONRPCError struct { - // A number that indicates the error type that occurred. - Code int `json:"code" yaml:"code" mapstructure:"code"` - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` - - // A string providing a short description of the error. - Message string `json:"message" yaml:"message" mapstructure:"message"` -} - -// Represents a JSON-RPC 2.0 Error Response object. -type JSONRPCErrorResponse struct { - // An object describing the error that occurred. - Error JSONRPCErrorResponseError `json:"error" yaml:"error" mapstructure:"error"` - - // The identifier established by the client. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` -} - -// Represents a JSON-RPC 2.0 Error object, included in an error response. -type JSONRPCErrorResponseError struct { - // A number that indicates the error type that occurred. - Code int `json:"code" yaml:"code" mapstructure:"code"` - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` - - // A string providing a short description of the error. - Message string `json:"message" yaml:"message" mapstructure:"message"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *JSONRPCErrorResponseError) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - var jSONRPCErrorResponseError_0 JSONRPCErrorResponseError_0 - var jSONRPCErrorResponseError_1 JSONRPCErrorResponseError_1 - var jSONRPCErrorResponseError_2 JSONRPCErrorResponseError_2 - var jSONRPCErrorResponseError_3 JSONRPCErrorResponseError_3 - var jSONRPCErrorResponseError_4 JSONRPCErrorResponseError_4 - var jSONRPCErrorResponseError_5 JSONRPCErrorResponseError_5 - var jSONRPCErrorResponseError_6 JSONRPCErrorResponseError_6 - var jSONRPCErrorResponseError_7 JSONRPCErrorResponseError_7 - var jSONRPCErrorResponseError_8 JSONRPCErrorResponseError_8 - var jSONRPCErrorResponseError_9 JSONRPCErrorResponseError_9 - var jSONRPCErrorResponseError_10 JSONRPCErrorResponseError_10 - var jSONRPCErrorResponseError_11 JSONRPCErrorResponseError_11 - var jSONRPCErrorResponseError_12 JSONRPCErrorResponseError_12 - var errs []error - if err := jSONRPCErrorResponseError_0.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := jSONRPCErrorResponseError_1.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := jSONRPCErrorResponseError_2.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := jSONRPCErrorResponseError_3.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := jSONRPCErrorResponseError_4.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := jSONRPCErrorResponseError_5.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := jSONRPCErrorResponseError_6.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := jSONRPCErrorResponseError_7.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := jSONRPCErrorResponseError_8.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := jSONRPCErrorResponseError_9.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := jSONRPCErrorResponseError_10.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := jSONRPCErrorResponseError_11.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := jSONRPCErrorResponseError_12.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if len(errs) == 13 { - return fmt.Errorf("all validators failed: %s", errors.Join(errs...)) - } - type Plain JSONRPCErrorResponseError - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = JSONRPCErrorResponseError(plain) - return nil -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *JSONRPCErrorResponse) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["error"]; raw != nil && !ok { - return fmt.Errorf("field error in JSONRPCErrorResponse: required") - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in JSONRPCErrorResponse: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in JSONRPCErrorResponse: required") - } - type Plain JSONRPCErrorResponse - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = JSONRPCErrorResponse(plain) - return nil -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *JSONRPCError) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["code"]; raw != nil && !ok { - return fmt.Errorf("field code in JSONRPCError: required") - } - if _, ok := raw["message"]; raw != nil && !ok { - return fmt.Errorf("field message in JSONRPCError: required") - } - type Plain JSONRPCError - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = JSONRPCError(plain) - return nil -} - -// Defines the base structure for any JSON-RPC 2.0 request, response, or -// notification. -type JSONRPCMessage struct { - // A unique identifier established by the client. It must be a String, a Number, - // or null. - // The server must reply with the same value in the response. This property is - // omitted for notifications. - Id interface{} `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id,omitempty"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *JSONRPCMessage) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in JSONRPCMessage: required") - } - type Plain JSONRPCMessage - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = JSONRPCMessage(plain) - return nil -} - -// Represents a JSON-RPC 2.0 Request object. -type JSONRPCRequest struct { - // A unique identifier established by the client. It must be a String, a Number, - // or null. - // The server must reply with the same value in the response. This property is - // omitted for notifications. - Id interface{} `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id,omitempty"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // A string containing the name of the method to be invoked. - Method string `json:"method" yaml:"method" mapstructure:"method"` - - // A structured value holding the parameter values to be used during the method - // invocation. - Params map[string]interface{} `json:"params,omitempty" yaml:"params,omitempty" mapstructure:"params,omitempty"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *JSONRPCRequest) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in JSONRPCRequest: required") - } - if _, ok := raw["method"]; raw != nil && !ok { - return fmt.Errorf("field method in JSONRPCRequest: required") - } - type Plain JSONRPCRequest - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = JSONRPCRequest(plain) - return nil -} - -// A discriminated union representing all possible JSON-RPC 2.0 responses -// for the A2A specification methods. -type JSONRPCResponse interface{} - -// Represents a successful JSON-RPC 2.0 Response object. -type JSONRPCSuccessResponse struct { - // The identifier established by the client. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The value of this member is determined by the method invoked on the Server. - Result interface{} `json:"result" yaml:"result" mapstructure:"result"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *JSONRPCSuccessResponse) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in JSONRPCSuccessResponse: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in JSONRPCSuccessResponse: required") - } - if _, ok := raw["result"]; raw != nil && !ok { - return fmt.Errorf("field result in JSONRPCSuccessResponse: required") - } - type Plain JSONRPCSuccessResponse - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = JSONRPCSuccessResponse(plain) - return nil -} - -// Defines parameters for listing all push notification configurations associated -// with a task. -type ListTaskPushNotificationConfigParams struct { - // The unique identifier of the task. - Id string `json:"id" yaml:"id" mapstructure:"id"` - - // Optional metadata associated with the request. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *ListTaskPushNotificationConfigParams) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in ListTaskPushNotificationConfigParams: required") - } - type Plain ListTaskPushNotificationConfigParams - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = ListTaskPushNotificationConfigParams(plain) - return nil -} - -// Represents a JSON-RPC request for the `tasks/pushNotificationConfig/list` -// method. -type ListTaskPushNotificationConfigRequest struct { - // The identifier for this request. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The method name. Must be 'tasks/pushNotificationConfig/list'. - Method string `json:"method" yaml:"method" mapstructure:"method"` - - // The parameters identifying the task whose configurations are to be listed. - Params ListTaskPushNotificationConfigParams `json:"params" yaml:"params" mapstructure:"params"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *ListTaskPushNotificationConfigRequest) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in ListTaskPushNotificationConfigRequest: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in ListTaskPushNotificationConfigRequest: required") - } - if _, ok := raw["method"]; raw != nil && !ok { - return fmt.Errorf("field method in ListTaskPushNotificationConfigRequest: required") - } - if _, ok := raw["params"]; raw != nil && !ok { - return fmt.Errorf("field params in ListTaskPushNotificationConfigRequest: required") - } - type Plain ListTaskPushNotificationConfigRequest - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = ListTaskPushNotificationConfigRequest(plain) - return nil -} - -// Represents a JSON-RPC response for the `tasks/pushNotificationConfig/list` -// method. -type ListTaskPushNotificationConfigResponse interface{} - -// Represents a successful JSON-RPC response for the -// `tasks/pushNotificationConfig/list` method. -type ListTaskPushNotificationConfigSuccessResponse struct { - // The identifier established by the client. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The result, containing an array of all push notification configurations for the - // task. - Result []TaskPushNotificationConfig `json:"result" yaml:"result" mapstructure:"result"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *ListTaskPushNotificationConfigSuccessResponse) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in ListTaskPushNotificationConfigSuccessResponse: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in ListTaskPushNotificationConfigSuccessResponse: required") - } - if _, ok := raw["result"]; raw != nil && !ok { - return fmt.Errorf("field result in ListTaskPushNotificationConfigSuccessResponse: required") - } - type Plain ListTaskPushNotificationConfigSuccessResponse - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = ListTaskPushNotificationConfigSuccessResponse(plain) - return nil -} - -// Represents a single message in the conversation between a user and an agent. -type Message struct { - // The context identifier for this message, used to group related interactions. - ContextId *string `json:"contextId,omitempty" yaml:"contextId,omitempty" mapstructure:"contextId,omitempty"` - - // The URIs of extensions that are relevant to this message. - Extensions []string `json:"extensions,omitempty" yaml:"extensions,omitempty" mapstructure:"extensions,omitempty"` - - // The type of this object, used as a discriminator. Always 'message' for a - // Message. - Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` - - // A unique identifier for the message, typically a UUID, generated by the sender. - MessageId string `json:"messageId" yaml:"messageId" mapstructure:"messageId"` - - // Optional metadata for extensions. The key is an extension-specific identifier. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` - - // An array of content parts that form the message body. A message can be - // composed of multiple parts of different types (e.g., text and files). - Parts []MessagePartsElem `json:"parts" yaml:"parts" mapstructure:"parts"` - - // A list of other task IDs that this message references for additional context. - ReferenceTaskIds []string `json:"referenceTaskIds,omitempty" yaml:"referenceTaskIds,omitempty" mapstructure:"referenceTaskIds,omitempty"` - - // Identifies the sender of the message. `user` for the client, `agent` for the - // service. - Role MessageRole `json:"role" yaml:"role" mapstructure:"role"` - - // The identifier of the task this message is part of. Can be omitted for the - // first message of a new task. - TaskId *string `json:"taskId,omitempty" yaml:"taskId,omitempty" mapstructure:"taskId,omitempty"` -} - -type MessagePartsElem interface{} - -type MessageRole string - -const MessageRoleAgent MessageRole = "agent" -const MessageRoleUser MessageRole = "user" - -var enumValues_MessageRole = []interface{}{ - "agent", - "user", -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *MessageRole) UnmarshalJSON(value []byte) error { - var v string - if err := json.Unmarshal(value, &v); err != nil { - return err - } - var ok bool - for _, expected := range enumValues_MessageRole { - if reflect.DeepEqual(v, expected) { - ok = true - break - } - } - if !ok { - return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_MessageRole, v) - } - *j = MessageRole(v) - return nil -} - -// Defines configuration options for a `message/send` or `message/stream` request. -type MessageSendConfiguration struct { - // A list of output MIME types the client is prepared to accept in the response. - AcceptedOutputModes []string `json:"acceptedOutputModes,omitempty" yaml:"acceptedOutputModes,omitempty" mapstructure:"acceptedOutputModes,omitempty"` - - // If true, the client will wait for the task to complete. The server may reject - // this if the task is long-running. - Blocking *bool `json:"blocking,omitempty" yaml:"blocking,omitempty" mapstructure:"blocking,omitempty"` - - // The number of most recent messages from the task's history to retrieve in the - // response. - HistoryLength *int `json:"historyLength,omitempty" yaml:"historyLength,omitempty" mapstructure:"historyLength,omitempty"` - - // Configuration for the agent to send push notifications for updates after the - // initial response. - PushNotificationConfig *PushNotificationConfig `json:"pushNotificationConfig,omitempty" yaml:"pushNotificationConfig,omitempty" mapstructure:"pushNotificationConfig,omitempty"` -} - -// Defines the parameters for a request to send a message to an agent. This can be -// used -// to create a new task, continue an existing one, or restart a task. -type MessageSendParams struct { - // Optional configuration for the send request. - Configuration *MessageSendConfiguration `json:"configuration,omitempty" yaml:"configuration,omitempty" mapstructure:"configuration,omitempty"` - - // The message object being sent to the agent. - Message Message `json:"message" yaml:"message" mapstructure:"message"` - - // Optional metadata for extensions. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *MessageSendParams) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["message"]; raw != nil && !ok { - return fmt.Errorf("field message in MessageSendParams: required") - } - type Plain MessageSendParams - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = MessageSendParams(plain) - return nil -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *Message) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["kind"]; raw != nil && !ok { - return fmt.Errorf("field kind in Message: required") - } - if _, ok := raw["messageId"]; raw != nil && !ok { - return fmt.Errorf("field messageId in Message: required") - } - if _, ok := raw["parts"]; raw != nil && !ok { - return fmt.Errorf("field parts in Message: required") - } - if _, ok := raw["role"]; raw != nil && !ok { - return fmt.Errorf("field role in Message: required") - } - type Plain Message - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = Message(plain) - return nil -} - -// An error indicating that the requested method does not exist or is not -// available. -type MethodNotFoundError struct { - // The error code for a method not found error. - Code int `json:"code" yaml:"code" mapstructure:"code"` - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` - - // The error message. - Message string `json:"message" yaml:"message" mapstructure:"message"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *MethodNotFoundError) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["code"]; raw != nil && !ok { - return fmt.Errorf("field code in MethodNotFoundError: required") - } - type Plain MethodNotFoundError - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - if v, ok := raw["message"]; !ok || v == nil { - plain.Message = "Method not found" - } - *j = MethodNotFoundError(plain) - return nil -} - -// Defines a security scheme using mTLS authentication. -type MutualTLSSecurityScheme struct { - // An optional description for the security scheme. - Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` - - // The type of the security scheme. Must be 'mutualTLS'. - Type string `json:"type" yaml:"type" mapstructure:"type"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *MutualTLSSecurityScheme) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["type"]; raw != nil && !ok { - return fmt.Errorf("field type in MutualTLSSecurityScheme: required") - } - type Plain MutualTLSSecurityScheme - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = MutualTLSSecurityScheme(plain) - return nil -} - -// Defines a security scheme using OAuth 2.0. -type OAuth2SecurityScheme struct { - // An optional description for the security scheme. - Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` - - // An object containing configuration information for the supported OAuth 2.0 - // flows. - Flows OAuthFlows `json:"flows" yaml:"flows" mapstructure:"flows"` - - // URL to the oauth2 authorization server metadata - // [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414). TLS is required. - Oauth2MetadataUrl *string `json:"oauth2MetadataUrl,omitempty" yaml:"oauth2MetadataUrl,omitempty" mapstructure:"oauth2MetadataUrl,omitempty"` - - // The type of the security scheme. Must be 'oauth2'. - Type string `json:"type" yaml:"type" mapstructure:"type"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *OAuth2SecurityScheme) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["flows"]; raw != nil && !ok { - return fmt.Errorf("field flows in OAuth2SecurityScheme: required") - } - if _, ok := raw["type"]; raw != nil && !ok { - return fmt.Errorf("field type in OAuth2SecurityScheme: required") - } - type Plain OAuth2SecurityScheme - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = OAuth2SecurityScheme(plain) - return nil -} - -// Defines the configuration for the supported OAuth 2.0 flows. -type OAuthFlows struct { - // Configuration for the OAuth Authorization Code flow. Previously called - // accessCode in OpenAPI 2.0. - AuthorizationCode *AuthorizationCodeOAuthFlow `json:"authorizationCode,omitempty" yaml:"authorizationCode,omitempty" mapstructure:"authorizationCode,omitempty"` - - // Configuration for the OAuth Client Credentials flow. Previously called - // application in OpenAPI 2.0. - ClientCredentials *ClientCredentialsOAuthFlow `json:"clientCredentials,omitempty" yaml:"clientCredentials,omitempty" mapstructure:"clientCredentials,omitempty"` - - // Configuration for the OAuth Implicit flow. - Implicit *ImplicitOAuthFlow `json:"implicit,omitempty" yaml:"implicit,omitempty" mapstructure:"implicit,omitempty"` - - // Configuration for the OAuth Resource Owner Password flow. - Password *PasswordOAuthFlow `json:"password,omitempty" yaml:"password,omitempty" mapstructure:"password,omitempty"` -} - -// Defines a security scheme using OpenID Connect. -type OpenIdConnectSecurityScheme struct { - // An optional description for the security scheme. - Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` - - // The OpenID Connect Discovery URL for the OIDC provider's metadata. - OpenIdConnectUrl string `json:"openIdConnectUrl" yaml:"openIdConnectUrl" mapstructure:"openIdConnectUrl"` - - // The type of the security scheme. Must be 'openIdConnect'. - Type string `json:"type" yaml:"type" mapstructure:"type"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *OpenIdConnectSecurityScheme) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["openIdConnectUrl"]; raw != nil && !ok { - return fmt.Errorf("field openIdConnectUrl in OpenIdConnectSecurityScheme: required") - } - if _, ok := raw["type"]; raw != nil && !ok { - return fmt.Errorf("field type in OpenIdConnectSecurityScheme: required") - } - type Plain OpenIdConnectSecurityScheme - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = OpenIdConnectSecurityScheme(plain) - return nil -} - -// A discriminated union representing a part of a message or artifact, which can -// be text, a file, or structured data. -type Part interface{} - -// Defines base properties common to all message or artifact parts. -type PartBase struct { - // Optional metadata associated with this part. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` -} - -// Defines configuration details for the OAuth 2.0 Resource Owner Password flow. -type PasswordOAuthFlow struct { - // The URL to be used for obtaining refresh tokens. This MUST be a URL. - RefreshUrl *string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty" mapstructure:"refreshUrl,omitempty"` - - // The available scopes for the OAuth2 security scheme. A map between the scope - // name and a short description for it. - Scopes map[string]string `json:"scopes" yaml:"scopes" mapstructure:"scopes"` - - // The token URL to be used for this flow. This MUST be a URL. - TokenUrl string `json:"tokenUrl" yaml:"tokenUrl" mapstructure:"tokenUrl"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *PasswordOAuthFlow) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["scopes"]; raw != nil && !ok { - return fmt.Errorf("field scopes in PasswordOAuthFlow: required") - } - if _, ok := raw["tokenUrl"]; raw != nil && !ok { - return fmt.Errorf("field tokenUrl in PasswordOAuthFlow: required") - } - type Plain PasswordOAuthFlow - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = PasswordOAuthFlow(plain) - return nil -} - -// Defines authentication details for a push notification endpoint. -type PushNotificationAuthenticationInfo struct { - // Optional credentials required by the push notification endpoint. - Credentials *string `json:"credentials,omitempty" yaml:"credentials,omitempty" mapstructure:"credentials,omitempty"` - - // A list of supported authentication schemes (e.g., 'Basic', 'Bearer'). - Schemes []string `json:"schemes" yaml:"schemes" mapstructure:"schemes"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *PushNotificationAuthenticationInfo) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["schemes"]; raw != nil && !ok { - return fmt.Errorf("field schemes in PushNotificationAuthenticationInfo: required") - } - type Plain PushNotificationAuthenticationInfo - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = PushNotificationAuthenticationInfo(plain) - return nil -} - -// Defines the configuration for setting up push notifications for task updates. -type PushNotificationConfig struct { - // Optional authentication details for the agent to use when calling the - // notification URL. - Authentication *PushNotificationAuthenticationInfo `json:"authentication,omitempty" yaml:"authentication,omitempty" mapstructure:"authentication,omitempty"` - - // A unique ID for the push notification configuration, set by the client - // to support multiple notification callbacks. - Id *string `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id,omitempty"` - - // A unique token for this task or session to validate incoming push - // notifications. - Token *string `json:"token,omitempty" yaml:"token,omitempty" mapstructure:"token,omitempty"` - - // The callback URL where the agent should send push notifications. - Url string `json:"url" yaml:"url" mapstructure:"url"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *PushNotificationConfig) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["url"]; raw != nil && !ok { - return fmt.Errorf("field url in PushNotificationConfig: required") - } - type Plain PushNotificationConfig - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = PushNotificationConfig(plain) - return nil -} - -// An A2A-specific error indicating that the agent does not support push -// notifications. -type PushNotificationNotSupportedError struct { - // The error code for when push notifications are not supported. - Code int `json:"code" yaml:"code" mapstructure:"code"` - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` - - // The error message. - Message string `json:"message" yaml:"message" mapstructure:"message"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *PushNotificationNotSupportedError) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["code"]; raw != nil && !ok { - return fmt.Errorf("field code in PushNotificationNotSupportedError: required") - } - type Plain PushNotificationNotSupportedError - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - if v, ok := raw["message"]; !ok || v == nil { - plain.Message = "Push Notification is not supported" - } - *j = PushNotificationNotSupportedError(plain) - return nil -} - -// Defines a security scheme that can be used to secure an agent's endpoints. -// This is a discriminated union type based on the OpenAPI 3.0 Security Scheme -// Object. -type SecurityScheme interface{} - -// Defines base properties shared by all security scheme objects. -type SecuritySchemeBase struct { - // An optional description for the security scheme. - Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` -} - -// Represents a JSON-RPC request for the `message/send` method. -type SendMessageRequest struct { - // The identifier for this request. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The method name. Must be 'message/send'. - Method string `json:"method" yaml:"method" mapstructure:"method"` - - // The parameters for sending a message. - Params MessageSendParams `json:"params" yaml:"params" mapstructure:"params"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *SendMessageRequest) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in SendMessageRequest: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in SendMessageRequest: required") - } - if _, ok := raw["method"]; raw != nil && !ok { - return fmt.Errorf("field method in SendMessageRequest: required") - } - if _, ok := raw["params"]; raw != nil && !ok { - return fmt.Errorf("field params in SendMessageRequest: required") - } - type Plain SendMessageRequest - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = SendMessageRequest(plain) - return nil -} - -// Represents a JSON-RPC response for the `message/send` method. -type SendMessageResponse interface{} - -// Represents a successful JSON-RPC response for the `message/send` method. -type SendMessageSuccessResponse struct { - // The identifier established by the client. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The result, which can be a direct reply Message or the initial Task object. - Result SendMessageSuccessResponseResult `json:"result" yaml:"result" mapstructure:"result"` -} - -// Represents a single, stateful operation or conversation between a client and an -// agent. -type SendMessageSuccessResponseResult struct { - // A collection of artifacts generated by the agent during the execution of the - // task. - Artifacts []Artifact `json:"artifacts,omitempty" yaml:"artifacts,omitempty" mapstructure:"artifacts,omitempty"` - - // A server-generated identifier for maintaining context across multiple related - // tasks or interactions. - ContextId string `json:"contextId" yaml:"contextId" mapstructure:"contextId"` - - // The URIs of extensions that are relevant to this message. - Extensions []string `json:"extensions,omitempty" yaml:"extensions,omitempty" mapstructure:"extensions,omitempty"` - - // An array of messages exchanged during the task, representing the conversation - // history. - History []Message `json:"history,omitempty" yaml:"history,omitempty" mapstructure:"history,omitempty"` - - // A unique identifier for the task, generated by the server for a new task. - Id string `json:"id" yaml:"id" mapstructure:"id"` - - // The type of this object, used as a discriminator. Always 'task' for a Task. - Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` - - // A unique identifier for the message, typically a UUID, generated by the sender. - MessageId string `json:"messageId" yaml:"messageId" mapstructure:"messageId"` - - // Optional metadata for extensions. The key is an extension-specific identifier. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` - - // An array of content parts that form the message body. A message can be - // composed of multiple parts of different types (e.g., text and files). - Parts []MessagePartsElem `json:"parts" yaml:"parts" mapstructure:"parts"` - - // A list of other task IDs that this message references for additional context. - ReferenceTaskIds []string `json:"referenceTaskIds,omitempty" yaml:"referenceTaskIds,omitempty" mapstructure:"referenceTaskIds,omitempty"` - - // Identifies the sender of the message. `user` for the client, `agent` for the - // service. - Role MessageRole `json:"role" yaml:"role" mapstructure:"role"` - - // The current status of the task, including its state and a descriptive message. - Status TaskStatus `json:"status" yaml:"status" mapstructure:"status"` - - // The identifier of the task this message is part of. Can be omitted for the - // first message of a new task. - TaskId *string `json:"taskId,omitempty" yaml:"taskId,omitempty" mapstructure:"taskId,omitempty"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *SendMessageSuccessResponseResult) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - var sendMessageSuccessResponseResult_0 SendMessageSuccessResponseResult_0 - var sendMessageSuccessResponseResult_1 SendMessageSuccessResponseResult_1 - var errs []error - if err := sendMessageSuccessResponseResult_0.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := sendMessageSuccessResponseResult_1.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if len(errs) == 2 { - return fmt.Errorf("all validators failed: %s", errors.Join(errs...)) - } - type Plain SendMessageSuccessResponseResult - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = SendMessageSuccessResponseResult(plain) - return nil -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *SendMessageSuccessResponse) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in SendMessageSuccessResponse: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in SendMessageSuccessResponse: required") - } - if _, ok := raw["result"]; raw != nil && !ok { - return fmt.Errorf("field result in SendMessageSuccessResponse: required") - } - type Plain SendMessageSuccessResponse - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = SendMessageSuccessResponse(plain) - return nil -} - -// Represents a JSON-RPC request for the `message/stream` method. -type SendStreamingMessageRequest struct { - // The identifier for this request. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The method name. Must be 'message/stream'. - Method string `json:"method" yaml:"method" mapstructure:"method"` - - // The parameters for sending a message. - Params MessageSendParams `json:"params" yaml:"params" mapstructure:"params"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *SendStreamingMessageRequest) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in SendStreamingMessageRequest: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in SendStreamingMessageRequest: required") - } - if _, ok := raw["method"]; raw != nil && !ok { - return fmt.Errorf("field method in SendStreamingMessageRequest: required") - } - if _, ok := raw["params"]; raw != nil && !ok { - return fmt.Errorf("field params in SendStreamingMessageRequest: required") - } - type Plain SendStreamingMessageRequest - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = SendStreamingMessageRequest(plain) - return nil -} - -// Represents a JSON-RPC response for the `message/stream` method. -type SendStreamingMessageResponse interface{} - -// Represents a successful JSON-RPC response for the `message/stream` method. -// The server may send multiple response objects for a single request. -type SendStreamingMessageSuccessResponse struct { - // The identifier established by the client. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The result, which can be a Message, Task, or a streaming update event. - Result SendStreamingMessageSuccessResponseResult `json:"result" yaml:"result" mapstructure:"result"` -} - -// Represents a single, stateful operation or conversation between a client and an -// agent. -type SendStreamingMessageSuccessResponseResult struct { - // If true, the content of this artifact should be appended to a previously sent - // artifact with the same ID. - Append *bool `json:"append,omitempty" yaml:"append,omitempty" mapstructure:"append,omitempty"` - - // The artifact that was generated or updated. - Artifact Artifact `json:"artifact" yaml:"artifact" mapstructure:"artifact"` - - // A collection of artifacts generated by the agent during the execution of the - // task. - Artifacts []Artifact `json:"artifacts,omitempty" yaml:"artifacts,omitempty" mapstructure:"artifacts,omitempty"` - - // A server-generated identifier for maintaining context across multiple related - // tasks or interactions. - ContextId string `json:"contextId" yaml:"contextId" mapstructure:"contextId"` - - // The URIs of extensions that are relevant to this message. - Extensions []string `json:"extensions,omitempty" yaml:"extensions,omitempty" mapstructure:"extensions,omitempty"` - - // If true, this is the final event in the stream for this interaction. - Final bool `json:"final" yaml:"final" mapstructure:"final"` - - // An array of messages exchanged during the task, representing the conversation - // history. - History []Message `json:"history,omitempty" yaml:"history,omitempty" mapstructure:"history,omitempty"` - - // A unique identifier for the task, generated by the server for a new task. - Id string `json:"id" yaml:"id" mapstructure:"id"` - - // The type of this object, used as a discriminator. Always 'task' for a Task. - Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` - - // If true, this is the final chunk of the artifact. - LastChunk *bool `json:"lastChunk,omitempty" yaml:"lastChunk,omitempty" mapstructure:"lastChunk,omitempty"` - - // A unique identifier for the message, typically a UUID, generated by the sender. - MessageId string `json:"messageId" yaml:"messageId" mapstructure:"messageId"` - - // Optional metadata for extensions. The key is an extension-specific identifier. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` - - // An array of content parts that form the message body. A message can be - // composed of multiple parts of different types (e.g., text and files). - Parts []MessagePartsElem `json:"parts" yaml:"parts" mapstructure:"parts"` - - // A list of other task IDs that this message references for additional context. - ReferenceTaskIds []string `json:"referenceTaskIds,omitempty" yaml:"referenceTaskIds,omitempty" mapstructure:"referenceTaskIds,omitempty"` - - // Identifies the sender of the message. `user` for the client, `agent` for the - // service. - Role MessageRole `json:"role" yaml:"role" mapstructure:"role"` - - // The current status of the task, including its state and a descriptive message. - Status TaskStatus `json:"status" yaml:"status" mapstructure:"status"` - - // The identifier of the task this message is part of. Can be omitted for the - // first message of a new task. - TaskId string `json:"taskId" yaml:"taskId" mapstructure:"taskId"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *SendStreamingMessageSuccessResponseResult) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - var sendStreamingMessageSuccessResponseResult_0 SendStreamingMessageSuccessResponseResult_0 - var sendStreamingMessageSuccessResponseResult_1 SendStreamingMessageSuccessResponseResult_1 - var sendStreamingMessageSuccessResponseResult_2 SendStreamingMessageSuccessResponseResult_2 - var sendStreamingMessageSuccessResponseResult_3 SendStreamingMessageSuccessResponseResult_3 - var errs []error - if err := sendStreamingMessageSuccessResponseResult_0.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := sendStreamingMessageSuccessResponseResult_1.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := sendStreamingMessageSuccessResponseResult_2.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if err := sendStreamingMessageSuccessResponseResult_3.UnmarshalJSON(value); err != nil { - errs = append(errs, err) - } - if len(errs) == 4 { - return fmt.Errorf("all validators failed: %s", errors.Join(errs...)) - } - type Plain SendStreamingMessageSuccessResponseResult - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = SendStreamingMessageSuccessResponseResult(plain) - return nil -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *SendStreamingMessageSuccessResponse) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in SendStreamingMessageSuccessResponse: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in SendStreamingMessageSuccessResponse: required") - } - if _, ok := raw["result"]; raw != nil && !ok { - return fmt.Errorf("field result in SendStreamingMessageSuccessResponse: required") - } - type Plain SendStreamingMessageSuccessResponse - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = SendStreamingMessageSuccessResponse(plain) - return nil -} - -// Represents a JSON-RPC request for the `tasks/pushNotificationConfig/set` method. -type SetTaskPushNotificationConfigRequest struct { - // The identifier for this request. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The method name. Must be 'tasks/pushNotificationConfig/set'. - Method string `json:"method" yaml:"method" mapstructure:"method"` - - // The parameters for setting the push notification configuration. - Params TaskPushNotificationConfig `json:"params" yaml:"params" mapstructure:"params"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *SetTaskPushNotificationConfigRequest) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in SetTaskPushNotificationConfigRequest: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in SetTaskPushNotificationConfigRequest: required") - } - if _, ok := raw["method"]; raw != nil && !ok { - return fmt.Errorf("field method in SetTaskPushNotificationConfigRequest: required") - } - if _, ok := raw["params"]; raw != nil && !ok { - return fmt.Errorf("field params in SetTaskPushNotificationConfigRequest: required") - } - type Plain SetTaskPushNotificationConfigRequest - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = SetTaskPushNotificationConfigRequest(plain) - return nil -} - -// Represents a JSON-RPC response for the `tasks/pushNotificationConfig/set` -// method. -type SetTaskPushNotificationConfigResponse interface{} - -// Represents a successful JSON-RPC response for the -// `tasks/pushNotificationConfig/set` method. -type SetTaskPushNotificationConfigSuccessResponse struct { - // The identifier established by the client. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The result, containing the configured push notification settings. - Result TaskPushNotificationConfig `json:"result" yaml:"result" mapstructure:"result"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *SetTaskPushNotificationConfigSuccessResponse) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in SetTaskPushNotificationConfigSuccessResponse: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in SetTaskPushNotificationConfigSuccessResponse: required") - } - if _, ok := raw["result"]; raw != nil && !ok { - return fmt.Errorf("field result in SetTaskPushNotificationConfigSuccessResponse: required") - } - type Plain SetTaskPushNotificationConfigSuccessResponse - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = SetTaskPushNotificationConfigSuccessResponse(plain) - return nil -} - -// Represents a single, stateful operation or conversation between a client and an -// agent. -type Task struct { - // A collection of artifacts generated by the agent during the execution of the - // task. - Artifacts []Artifact `json:"artifacts,omitempty" yaml:"artifacts,omitempty" mapstructure:"artifacts,omitempty"` - - // A server-generated identifier for maintaining context across multiple related - // tasks or interactions. - ContextId string `json:"contextId" yaml:"contextId" mapstructure:"contextId"` - - // An array of messages exchanged during the task, representing the conversation - // history. - History []Message `json:"history,omitempty" yaml:"history,omitempty" mapstructure:"history,omitempty"` - - // A unique identifier for the task, generated by the server for a new task. - Id string `json:"id" yaml:"id" mapstructure:"id"` - - // The type of this object, used as a discriminator. Always 'task' for a Task. - Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` - - // Optional metadata for extensions. The key is an extension-specific identifier. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` - - // The current status of the task, including its state and a descriptive message. - Status TaskStatus `json:"status" yaml:"status" mapstructure:"status"` -} - -// An event sent by the agent to notify the client that an artifact has been -// generated or updated. This is typically used in streaming models. -type TaskArtifactUpdateEvent struct { - // If true, the content of this artifact should be appended to a previously sent - // artifact with the same ID. - Append *bool `json:"append,omitempty" yaml:"append,omitempty" mapstructure:"append,omitempty"` - - // The artifact that was generated or updated. - Artifact Artifact `json:"artifact" yaml:"artifact" mapstructure:"artifact"` - - // The context ID associated with the task. - ContextId string `json:"contextId" yaml:"contextId" mapstructure:"contextId"` - - // The type of this event, used as a discriminator. Always 'artifact-update'. - Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` - - // If true, this is the final chunk of the artifact. - LastChunk *bool `json:"lastChunk,omitempty" yaml:"lastChunk,omitempty" mapstructure:"lastChunk,omitempty"` - - // Optional metadata for extensions. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` - - // The ID of the task this artifact belongs to. - TaskId string `json:"taskId" yaml:"taskId" mapstructure:"taskId"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *TaskArtifactUpdateEvent) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["artifact"]; raw != nil && !ok { - return fmt.Errorf("field artifact in TaskArtifactUpdateEvent: required") - } - if _, ok := raw["contextId"]; raw != nil && !ok { - return fmt.Errorf("field contextId in TaskArtifactUpdateEvent: required") - } - if _, ok := raw["kind"]; raw != nil && !ok { - return fmt.Errorf("field kind in TaskArtifactUpdateEvent: required") - } - if _, ok := raw["taskId"]; raw != nil && !ok { - return fmt.Errorf("field taskId in TaskArtifactUpdateEvent: required") - } - type Plain TaskArtifactUpdateEvent - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = TaskArtifactUpdateEvent(plain) - return nil -} - -// Defines parameters containing a task ID, used for simple task operations. -type TaskIdParams struct { - // The unique identifier of the task. - Id string `json:"id" yaml:"id" mapstructure:"id"` - - // Optional metadata associated with the request. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *TaskIdParams) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in TaskIdParams: required") - } - type Plain TaskIdParams - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = TaskIdParams(plain) - return nil -} - -// An A2A-specific error indicating that the task is in a state where it cannot be -// canceled. -type TaskNotCancelableError struct { - // The error code for a task that cannot be canceled. - Code int `json:"code" yaml:"code" mapstructure:"code"` - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` - - // The error message. - Message string `json:"message" yaml:"message" mapstructure:"message"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *TaskNotCancelableError) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["code"]; raw != nil && !ok { - return fmt.Errorf("field code in TaskNotCancelableError: required") - } - type Plain TaskNotCancelableError - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - if v, ok := raw["message"]; !ok || v == nil { - plain.Message = "Task cannot be canceled" - } - *j = TaskNotCancelableError(plain) - return nil -} - -// An A2A-specific error indicating that the requested task ID was not found. -type TaskNotFoundError struct { - // The error code for a task not found error. - Code int `json:"code" yaml:"code" mapstructure:"code"` - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` - - // The error message. - Message string `json:"message" yaml:"message" mapstructure:"message"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *TaskNotFoundError) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["code"]; raw != nil && !ok { - return fmt.Errorf("field code in TaskNotFoundError: required") - } - type Plain TaskNotFoundError - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - if v, ok := raw["message"]; !ok || v == nil { - plain.Message = "Task not found" - } - *j = TaskNotFoundError(plain) - return nil -} - -// A container associating a push notification configuration with a specific task. -type TaskPushNotificationConfig struct { - // The push notification configuration for this task. - PushNotificationConfig PushNotificationConfig `json:"pushNotificationConfig" yaml:"pushNotificationConfig" mapstructure:"pushNotificationConfig"` - - // The ID of the task. - TaskId string `json:"taskId" yaml:"taskId" mapstructure:"taskId"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *TaskPushNotificationConfig) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["pushNotificationConfig"]; raw != nil && !ok { - return fmt.Errorf("field pushNotificationConfig in TaskPushNotificationConfig: required") - } - if _, ok := raw["taskId"]; raw != nil && !ok { - return fmt.Errorf("field taskId in TaskPushNotificationConfig: required") - } - type Plain TaskPushNotificationConfig - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = TaskPushNotificationConfig(plain) - return nil -} - -// Defines parameters for querying a task, with an option to limit history length. -type TaskQueryParams struct { - // The number of most recent messages from the task's history to retrieve. - HistoryLength *int `json:"historyLength,omitempty" yaml:"historyLength,omitempty" mapstructure:"historyLength,omitempty"` - - // The unique identifier of the task. - Id string `json:"id" yaml:"id" mapstructure:"id"` - - // Optional metadata associated with the request. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *TaskQueryParams) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in TaskQueryParams: required") - } - type Plain TaskQueryParams - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = TaskQueryParams(plain) - return nil -} - -// Represents a JSON-RPC request for the `tasks/resubscribe` method, used to resume -// a streaming connection. -type TaskResubscriptionRequest struct { - // The identifier for this request. - Id interface{} `json:"id" yaml:"id" mapstructure:"id"` - - // The version of the JSON-RPC protocol. MUST be exactly "2.0". - Jsonrpc string `json:"jsonrpc" yaml:"jsonrpc" mapstructure:"jsonrpc"` - - // The method name. Must be 'tasks/resubscribe'. - Method string `json:"method" yaml:"method" mapstructure:"method"` - - // The parameters identifying the task to resubscribe to. - Params TaskIdParams `json:"params" yaml:"params" mapstructure:"params"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *TaskResubscriptionRequest) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in TaskResubscriptionRequest: required") - } - if _, ok := raw["jsonrpc"]; raw != nil && !ok { - return fmt.Errorf("field jsonrpc in TaskResubscriptionRequest: required") - } - if _, ok := raw["method"]; raw != nil && !ok { - return fmt.Errorf("field method in TaskResubscriptionRequest: required") - } - if _, ok := raw["params"]; raw != nil && !ok { - return fmt.Errorf("field params in TaskResubscriptionRequest: required") - } - type Plain TaskResubscriptionRequest - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = TaskResubscriptionRequest(plain) - return nil -} - -type TaskState string - -const TaskStateAuthRequired TaskState = "auth-required" -const TaskStateCanceled TaskState = "canceled" -const TaskStateCompleted TaskState = "completed" -const TaskStateFailed TaskState = "failed" -const TaskStateInputRequired TaskState = "input-required" -const TaskStateRejected TaskState = "rejected" -const TaskStateSubmitted TaskState = "submitted" -const TaskStateUnknown TaskState = "unknown" -const TaskStateWorking TaskState = "working" - -var enumValues_TaskState = []interface{}{ - "submitted", - "working", - "input-required", - "completed", - "canceled", - "failed", - "rejected", - "auth-required", - "unknown", -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *TaskState) UnmarshalJSON(value []byte) error { - var v string - if err := json.Unmarshal(value, &v); err != nil { - return err - } - var ok bool - for _, expected := range enumValues_TaskState { - if reflect.DeepEqual(v, expected) { - ok = true - break - } - } - if !ok { - return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_TaskState, v) - } - *j = TaskState(v) - return nil -} - -// Represents the status of a task at a specific point in time. -type TaskStatus struct { - // An optional, human-readable message providing more details about the current - // status. - Message *Message `json:"message,omitempty" yaml:"message,omitempty" mapstructure:"message,omitempty"` - - // The current state of the task's lifecycle. - State TaskState `json:"state" yaml:"state" mapstructure:"state"` - - // An ISO 8601 datetime string indicating when this status was recorded. - Timestamp *string `json:"timestamp,omitempty" yaml:"timestamp,omitempty" mapstructure:"timestamp,omitempty"` -} - -// An event sent by the agent to notify the client of a change in a task's status. -// This is typically used in streaming or subscription models. -type TaskStatusUpdateEvent struct { - // The context ID associated with the task. - ContextId string `json:"contextId" yaml:"contextId" mapstructure:"contextId"` - - // If true, this is the final event in the stream for this interaction. - Final bool `json:"final" yaml:"final" mapstructure:"final"` - - // The type of this event, used as a discriminator. Always 'status-update'. - Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` - - // Optional metadata for extensions. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` - - // The new status of the task. - Status TaskStatus `json:"status" yaml:"status" mapstructure:"status"` - - // The ID of the task that was updated. - TaskId string `json:"taskId" yaml:"taskId" mapstructure:"taskId"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *TaskStatusUpdateEvent) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["contextId"]; raw != nil && !ok { - return fmt.Errorf("field contextId in TaskStatusUpdateEvent: required") - } - if _, ok := raw["final"]; raw != nil && !ok { - return fmt.Errorf("field final in TaskStatusUpdateEvent: required") - } - if _, ok := raw["kind"]; raw != nil && !ok { - return fmt.Errorf("field kind in TaskStatusUpdateEvent: required") - } - if _, ok := raw["status"]; raw != nil && !ok { - return fmt.Errorf("field status in TaskStatusUpdateEvent: required") - } - if _, ok := raw["taskId"]; raw != nil && !ok { - return fmt.Errorf("field taskId in TaskStatusUpdateEvent: required") - } - type Plain TaskStatusUpdateEvent - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = TaskStatusUpdateEvent(plain) - return nil -} - -type JSONRPCErrorResponseError_9 = UnsupportedOperationError -type SendMessageSuccessResponseResult_0 = Task - -// UnmarshalJSON implements json.Unmarshaler. -func (j *UnsupportedOperationError) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["code"]; raw != nil && !ok { - return fmt.Errorf("field code in UnsupportedOperationError: required") - } - type Plain UnsupportedOperationError - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - if v, ok := raw["message"]; !ok || v == nil { - plain.Message = "This operation is not supported" - } - *j = UnsupportedOperationError(plain) - return nil -} - -// An A2A-specific error indicating that the requested operation is not supported -// by the agent. -type UnsupportedOperationError struct { - // The error code for an unsupported operation. - Code int `json:"code" yaml:"code" mapstructure:"code"` - - // A primitive or structured value containing additional information about the - // error. - // This may be omitted. - Data interface{} `json:"data,omitempty" yaml:"data,omitempty" mapstructure:"data,omitempty"` - - // The error message. - Message string `json:"message" yaml:"message" mapstructure:"message"` -} - -type JSONRPCErrorResponseError_0 = JSONRPCError -type GetTaskPushNotificationConfigRequestParams_1 = GetTaskPushNotificationConfigParams -type GetTaskPushNotificationConfigRequestParams_0 = TaskIdParams -type JSONRPCErrorResponseError_12 = AuthenticatedExtendedCardNotConfiguredError -type FilePartFile_1 = FileWithUri -type FilePartFile_0 = FileWithBytes -type JSONRPCErrorResponseError_11 = InvalidAgentResponseError -type JSONRPCErrorResponseError_10 = ContentTypeNotSupportedError -type SendStreamingMessageSuccessResponseResult_0 = Task -type SendStreamingMessageSuccessResponseResult_1 = Message -type SendStreamingMessageSuccessResponseResult_2 = TaskStatusUpdateEvent -type SendStreamingMessageSuccessResponseResult_3 = TaskArtifactUpdateEvent -type SendMessageSuccessResponseResult_1 = Message -type JSONRPCErrorResponseError_8 = PushNotificationNotSupportedError -type JSONRPCErrorResponseError_7 = TaskNotCancelableError -type JSONRPCErrorResponseError_6 = TaskNotFoundError -type JSONRPCErrorResponseError_5 = InternalError -type JSONRPCErrorResponseError_4 = InvalidParamsError -type JSONRPCErrorResponseError_3 = MethodNotFoundError -type JSONRPCErrorResponseError_2 = InvalidRequestError -type JSONRPCErrorResponseError_1 = JSONParseError - -// UnmarshalJSON implements json.Unmarshaler. -func (j *Task) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["contextId"]; raw != nil && !ok { - return fmt.Errorf("field contextId in Task: required") - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in Task: required") - } - if _, ok := raw["kind"]; raw != nil && !ok { - return fmt.Errorf("field kind in Task: required") - } - if _, ok := raw["status"]; raw != nil && !ok { - return fmt.Errorf("field status in Task: required") - } - type Plain Task - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = Task(plain) - return nil -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *TaskStatus) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["state"]; raw != nil && !ok { - return fmt.Errorf("field state in TaskStatus: required") - } - type Plain TaskStatus - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = TaskStatus(plain) - return nil -} - -// Represents a text segment within a message or artifact. -type TextPart struct { - // The type of this part, used as a discriminator. Always 'text'. - Kind string `json:"kind" yaml:"kind" mapstructure:"kind"` - - // Optional metadata associated with this part. - Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"` - - // The string content of the text part. - Text string `json:"text" yaml:"text" mapstructure:"text"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *TextPart) UnmarshalJSON(value []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(value, &raw); err != nil { - return err - } - if _, ok := raw["kind"]; raw != nil && !ok { - return fmt.Errorf("field kind in TextPart: required") - } - if _, ok := raw["text"]; raw != nil && !ok { - return fmt.Errorf("field text in TextPart: required") - } - type Plain TextPart - var plain Plain - if err := json.Unmarshal(value, &plain); err != nil { - return err - } - *j = TextPart(plain) - return nil -} - -type TransportProtocol string - -var enumValues_TransportProtocol = []interface{}{ - "JSONRPC", - "GRPC", - "HTTP+JSON", -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *TransportProtocol) UnmarshalJSON(value []byte) error { - var v string - if err := json.Unmarshal(value, &v); err != nil { - return err - } - var ok bool - for _, expected := range enumValues_TransportProtocol { - if reflect.DeepEqual(v, expected) { - ok = true - break - } - } - if !ok { - return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_TransportProtocol, v) - } - *j = TransportProtocol(v) - return nil -} - -const TransportProtocolJSONRPC TransportProtocol = "JSONRPC" -const TransportProtocolGRPC TransportProtocol = "GRPC" -const TransportProtocolHTTPJSON TransportProtocol = "HTTP+JSON" From 5e02a49f9ac9df6fec1a276351ca118a33122993 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Wed, 6 Aug 2025 19:06:42 +0000 Subject: [PATCH 09/23] file rename --- a2a/{types.go => core.go} | 2 +- a2a/push.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename a2a/{types.go => core.go} (99%) diff --git a/a2a/types.go b/a2a/core.go similarity index 99% rename from a2a/types.go rename to a2a/core.go index 97f5dcfd..e2970d19 100644 --- a/a2a/types.go +++ b/a2a/core.go @@ -317,7 +317,7 @@ type MessageSendConfig struct { // to create a new task, continue an existing one, or restart a task. type MessageSendParams struct { // Optional configuration for the send request. - Configuration *MessageSendConfig + Config *MessageSendConfig // The message object being sent to the agent. Message Message diff --git a/a2a/push.go b/a2a/push.go index 63a2a47a..e226929f 100644 --- a/a2a/push.go +++ b/a2a/push.go @@ -49,7 +49,7 @@ type DeleteTaskPushConfigParams struct { // A container associating a push notification configuration with a specific task. type TaskPushConfig struct { // The push notification configuration for this task. - PushConfig PushConfig + Config PushConfig // The ID of the task. TaskID TaskID From 0544c0aa91394e95fc2d5391c90a6f5106558616 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Wed, 6 Aug 2025 19:13:49 +0000 Subject: [PATCH 10/23] removed a type wrapper to match other sdk implementations --- a2a/push.go | 12 ------------ a2asrv/handler.go | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/a2a/push.go b/a2a/push.go index e226929f..7cae8825 100644 --- a/a2a/push.go +++ b/a2a/push.go @@ -22,18 +22,6 @@ type ListTaskPushConfigParams struct { Metadata map[string]any } -// Represents a request for the `tasks/pushNotificationConfig/set` method. -type SetTaskPushConfigParams struct { - // The parameters for setting the push notification configuration. - Config TaskPushConfig -} - -// Represents a config update result -type SetTaskPushConfigResult struct { - // The result, containing the configured push notification settings. - Config TaskPushConfig -} - // Defines parameters for deleting a specific push notification configuration for a task. type DeleteTaskPushConfigParams struct { // The unique identifier of the task. diff --git a/a2asrv/handler.go b/a2asrv/handler.go index 592a9964..6d26fbc5 100644 --- a/a2asrv/handler.go +++ b/a2asrv/handler.go @@ -22,7 +22,7 @@ type RequestHandler interface { OnHandleListTaskPushConfig(ctx context.Context, params a2a.ListTaskPushConfigParams) ([]a2a.TaskPushConfig, error) - OnHandleSetTaskPushConfig(ctx context.Context, params a2a.SetTaskPushConfigParams) (a2a.SetTaskPushConfigResult, error) + OnHandleSetTaskPushConfig(ctx context.Context, params a2a.TaskPushConfig) (a2a.TaskPushConfig, error) OnHandleDeleteTaskPushConfig(ctx context.Context, params a2a.DeleteTaskPushConfigParams) error } From 1b92e1df3ab3afbd613e71d303fca73e771d9dce Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Wed, 6 Aug 2025 19:17:38 +0000 Subject: [PATCH 11/23] added script doc, removed throwaway script --- tools/jsonrpc2spec.go | 171 ------------------------------------------ tools/jsonrpc_gen.sh | 8 ++ 2 files changed, 8 insertions(+), 171 deletions(-) delete mode 100644 tools/jsonrpc2spec.go diff --git a/tools/jsonrpc2spec.go b/tools/jsonrpc2spec.go deleted file mode 100644 index 1ccd75e5..00000000 --- a/tools/jsonrpc2spec.go +++ /dev/null @@ -1,171 +0,0 @@ -// Sanitizes proto-gener - -package main - -import ( - "bufio" - "flag" - "fmt" - "io" - "os" - "strings" -) - -func main() { - inPath := flag.String("in", "./internal/jsonrpc/spec.go", "path to json-schema file") - outPath := flag.String("out", "./a2a/types.go", "path to .go file with type definitions") - flag.Parse() - - inFile, err := os.Open(*inPath) - if err != nil { - fmt.Printf("Failed to open input file: %v\n", err) - os.Exit(1) - } - defer inFile.Close() - - converted, err := protoToStruct(inFile) - if err != nil { - fmt.Printf("Error: %v\n", err) - os.Exit(1) - } - - if err := os.WriteFile(*outPath, []byte(converted), 0644); err != nil { - fmt.Printf("Failed to write converted string to %s: %v\n", *outPath, err) - os.Exit(1) - } - - fmt.Printf("Successfully converted %s to %s\n", *inPath, *outPath) -} - -func protoToStruct(in io.Reader) (string, error) { - s := bufio.NewScanner(in) - - var result strings.Builder - - for s.Scan() { - line := s.Text() - - line = handleReplacements(line) - - if strings.HasPrefix(line, "import ") { - continue - } - - if strings.HasPrefix(line, "func ") || strings.HasPrefix(line, "var ") { - if err := skipPkgLevelBlock(s); err != nil { - return "", err - } - continue - } - - if !strings.HasPrefix(line, "type ") { - writeLine(&result, line) - continue - } - - handleStruct(s, line, &result) - } - - return result.String(), nil -} - -func handleStruct(s *bufio.Scanner, line string, result *strings.Builder) error { - if strings.Contains(line, " = ") { - return skipPkgLevelBlock(s) - } - - if !strings.HasSuffix(line, "{") { - writeLine(result, line) - return nil - } - - writeLine(result, line) - - if strings.Contains(line, "interface{}") { - return nil - } - - text, err := consumeStruct(s) - if err != nil { - return err - } - - result.WriteString(text) - return nil -} - -func consumeStruct(s *bufio.Scanner) (string, error) { - var b strings.Builder - - for s.Scan() { - line := s.Text() - - if shouldSkipStructLine(line) { - continue - } - - line = handleReplacements(line) - - if line == "}" { - writeLine(&b, line) - return b.String(), nil - } - - if tagStart := strings.IndexRune(line, '`'); tagStart >= 0 { - writeLine(&b, line[:tagStart-1]) - continue - } - - writeLine(&b, line) - } - return "", fmt.Errorf("unexpected EOF while skipping func") -} - -func shouldSkipStructLine(line string) bool { - prefixBlacklist := []string{ - "// The version of the JSON-RPC protocol. MUST be exactly", - "Jsonrpc string `json:", - "// The method name. Must be ", - "Method string `json:", - "// The identifier for this request.", - "// The identifier established by the client.", - "Id interface{}", - } - trimmed := strings.TrimSpace(line) - for _, p := range prefixBlacklist { - if strings.HasPrefix(trimmed, p) { - return true - } - } - return false -} - -func handleReplacements(line string) string { - replace := map[string]string{ - "Url": "URL", - "interface{}": "any", - "JSON-RPC response": "response", - "JSON-RPC request": "request", - "// UnmarshalJSON implements json.Unmarshaler.": "", - } - for old, new := range replace { - if strings.Contains(line, old) { - return strings.Replace(line, old, new, 1) - } - } - return line -} - -func skipPkgLevelBlock(s *bufio.Scanner) error { - for s.Scan() { - if line := s.Text(); line == "}" || line == ")" { - return nil - } - } - return fmt.Errorf("unexpected EOF while skipping pkg level block") -} - -func writeLine(sb *strings.Builder, line string) { - sb.WriteString(line) - sb.WriteByte('\n') -} diff --git a/tools/jsonrpc_gen.sh b/tools/jsonrpc_gen.sh index 0977521f..14eb1df7 100755 --- a/tools/jsonrpc_gen.sh +++ b/tools/jsonrpc_gen.sh @@ -1,4 +1,12 @@ #!/bin/bash +# Downloads the published A2A spec and generates go types +# in ./internal/jsonrpc/spec.go file. +# +# Ensure $GOBIN is in path and dependencies are installed: +# > go install github.com/atombender/go-jsonschema@latest +# +# Then run: +# > ./tools/jsonrpc_gen.sh set -euo pipefail From cb175478ac13fc3aec128031fc81ddfcba27e181 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Wed, 6 Aug 2025 19:28:18 +0000 Subject: [PATCH 12/23] cleanup and fill req context in --- a2a/core.go | 24 +++++++++++++----------- a2a/push.go | 9 --------- a2asrv/reqctx.go | 9 ++++++++- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/a2a/core.go b/a2a/core.go index e2970d19..8f4928d8 100644 --- a/a2a/core.go +++ b/a2a/core.go @@ -1,5 +1,7 @@ package a2a +import "time" + // Represents a response for non-streaming message send. type SendMessageResult interface { isSendMessageResult() @@ -112,8 +114,8 @@ type TaskStatus struct { // The current state of the task's lifecycle. State TaskState - // An ISO 8601 datetime string indicating when this status was recorded. - Timestamp *string + // A datetime indicating when this status was recorded. + Timestamp *time.Time } // Represents a file, data structure, or other resource generated by an agent @@ -157,11 +159,11 @@ type TaskArtifactUpdateEvent struct { // If true, this is the final chunk of the artifact. LastChunk *bool - // Optional metadata for extensions. - Metadata map[string]any - // The ID of the task this artifact belongs to. TaskID TaskID + + // Optional metadata for extensions. + Metadata map[string]any } // An event sent by the agent to notify the client of a change in a task's status. @@ -176,14 +178,14 @@ type TaskStatusUpdateEvent struct { // The type of this event, used as a discriminator. Always 'status-update'. Kind string - // Optional metadata for extensions. - Metadata map[string]any - // The new status of the task. Status TaskStatus // The ID of the task that was updated. TaskID TaskID + + // Optional metadata for extensions. + Metadata map[string]any } // A discriminated union representing a part of a message or artifact, which can @@ -201,11 +203,11 @@ type TextPart struct { // The type of this part, used as a discriminator. Always 'text'. Kind string - // Optional metadata associated with this part. - Metadata map[string]any - // The string content of the text part. Text string + + // Optional metadata associated with this part. + Metadata map[string]any } // Represents a structured data segment (e.g., JSON) within a message or artifact. diff --git a/a2a/push.go b/a2a/push.go index 7cae8825..3e7c1038 100644 --- a/a2a/push.go +++ b/a2a/push.go @@ -7,9 +7,6 @@ type GetTaskPushConfigParams struct { // The ID of the push notification configuration to retrieve. ConfigID *string - - // Optional metadata associated with the request. - Metadata map[string]any } // Defines parameters for listing all push notification configurations associated @@ -17,9 +14,6 @@ type GetTaskPushConfigParams struct { type ListTaskPushConfigParams struct { // The unique identifier of the task. TaskID TaskID - - // Optional metadata associated with the request. - Metadata map[string]any } // Defines parameters for deleting a specific push notification configuration for a task. @@ -27,9 +21,6 @@ type DeleteTaskPushConfigParams struct { // The unique identifier of the task. TaskID TaskID - // Optional metadata associated with the request. - Metadata map[string]any - // The ID of the push notification configuration to delete. ConfigID string } diff --git a/a2asrv/reqctx.go b/a2asrv/reqctx.go index 57b12a12..ac1cfb29 100644 --- a/a2asrv/reqctx.go +++ b/a2asrv/reqctx.go @@ -1,3 +1,10 @@ package a2asrv -type RequestContext struct{} +import "github.com/a2aproject/a2a-go/a2a" + +type RequestContext struct { + Request a2a.MessageSendParams + Task *a2a.Task + RelatedTasks []a2a.Task + ContextID string +} From 6fa0df2c6bcfbfec6ca74c3a603a6711ae383f4d Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Thu, 7 Aug 2025 06:43:56 +0000 Subject: [PATCH 13/23] fix missing message --- a2a/errors.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/a2a/errors.go b/a2a/errors.go index b3f6843a..8b21d762 100644 --- a/a2a/errors.go +++ b/a2a/errors.go @@ -17,5 +17,5 @@ var ( ErrInvalidRequest = errors.New("invalid request") - ErrAuthenticatedExtendedCardNotConfigured = errors.New("") + ErrAuthenticatedExtendedCardNotConfigured = errors.New("extended card not configured") ) From 5a1f79cbcdd9caf576c8a31052dc2c8ba477c1b1 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Thu, 7 Aug 2025 09:31:42 +0000 Subject: [PATCH 14/23] move interface to where it belongs --- a2asrv/reqctx.go | 9 ++++++++- a2asrv/tasks.go | 4 ---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/a2asrv/reqctx.go b/a2asrv/reqctx.go index ac1cfb29..76381c4e 100644 --- a/a2asrv/reqctx.go +++ b/a2asrv/reqctx.go @@ -1,6 +1,13 @@ package a2asrv -import "github.com/a2aproject/a2a-go/a2a" +import ( + "context" + "github.com/a2aproject/a2a-go/a2a" +) + +type RequestContextBuilder interface { + Build(ctx context.Context, p a2a.MessageSendParams, t *a2a.Task) RequestContext +} type RequestContext struct { Request a2a.MessageSendParams diff --git a/a2asrv/tasks.go b/a2asrv/tasks.go index 63a14f1f..daaf42ce 100644 --- a/a2asrv/tasks.go +++ b/a2asrv/tasks.go @@ -5,10 +5,6 @@ import ( "github.com/a2aproject/a2a-go/a2a" ) -type RequestContextBuilder interface { - Build(ctx context.Context, p a2a.MessageSendParams, t *a2a.Task) RequestContext -} - type PushNotifier interface { SendPush(ctx context.Context, task a2a.Task) error } From b54a22d027e4ff0789be77f034cc20aba1900cbb Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Thu, 7 Aug 2025 09:58:44 +0000 Subject: [PATCH 15/23] task id always needs to be present even if message won't be promoted to as task --- a2asrv/reqctx.go | 1 + 1 file changed, 1 insertion(+) diff --git a/a2asrv/reqctx.go b/a2asrv/reqctx.go index 76381c4e..b532b4d1 100644 --- a/a2asrv/reqctx.go +++ b/a2asrv/reqctx.go @@ -11,6 +11,7 @@ type RequestContextBuilder interface { type RequestContext struct { Request a2a.MessageSendParams + TaskID a2a.TaskID Task *a2a.Task RelatedTasks []a2a.Task ContextID string From 75512c04011cc1fe4a1b26616b7d820227b60a59 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Thu, 7 Aug 2025 14:39:43 +0000 Subject: [PATCH 16/23] add licenses --- a2a/agent.go | 14 ++++++++++++++ a2a/auth.go | 14 ++++++++++++++ a2a/core.go | 14 ++++++++++++++ a2a/errors.go | 14 ++++++++++++++ a2a/push.go | 14 ++++++++++++++ a2asrv/agent.go | 15 +++++++++++++++ a2asrv/events.go | 15 +++++++++++++++ a2asrv/handler.go | 14 ++++++++++++++ a2asrv/reqctx.go | 15 +++++++++++++++ a2asrv/tasks.go | 15 +++++++++++++++ internal/events/queue.go | 14 ++++++++++++++ internal/push/sender.go | 14 ++++++++++++++ internal/push/store.go | 14 ++++++++++++++ internal/task/store.go | 14 ++++++++++++++ 14 files changed, 200 insertions(+) diff --git a/a2a/agent.go b/a2a/agent.go index 23d66dee..eb4d8e23 100644 --- a/a2a/agent.go +++ b/a2a/agent.go @@ -1,3 +1,17 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package a2a // Defines optional capabilities supported by an agent. diff --git a/a2a/auth.go b/a2a/auth.go index 54e32ace..90364bee 100644 --- a/a2a/auth.go +++ b/a2a/auth.go @@ -1,3 +1,17 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package a2a // Defines a security scheme that can be used to secure an agent's endpoints. diff --git a/a2a/core.go b/a2a/core.go index 8f4928d8..3a9a5556 100644 --- a/a2a/core.go +++ b/a2a/core.go @@ -1,3 +1,17 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package a2a import "time" diff --git a/a2a/errors.go b/a2a/errors.go index 8b21d762..a6700dfd 100644 --- a/a2a/errors.go +++ b/a2a/errors.go @@ -1,3 +1,17 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package a2a import "errors" diff --git a/a2a/push.go b/a2a/push.go index 3e7c1038..2e9931c0 100644 --- a/a2a/push.go +++ b/a2a/push.go @@ -1,3 +1,17 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package a2a // Defines parameters for fetching a specific push notification configuration for a task. diff --git a/a2asrv/agent.go b/a2asrv/agent.go index 84a4e907..d723bb5d 100644 --- a/a2asrv/agent.go +++ b/a2asrv/agent.go @@ -1,7 +1,22 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package a2asrv import ( "context" + "github.com/a2aproject/a2a-go/a2a" ) diff --git a/a2asrv/events.go b/a2asrv/events.go index c76d9aae..80809a7d 100644 --- a/a2asrv/events.go +++ b/a2asrv/events.go @@ -1,7 +1,22 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package a2asrv import ( "context" + "github.com/a2aproject/a2a-go/a2a" ) diff --git a/a2asrv/handler.go b/a2asrv/handler.go index 6d26fbc5..fff0623d 100644 --- a/a2asrv/handler.go +++ b/a2asrv/handler.go @@ -1,3 +1,17 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package a2asrv import ( diff --git a/a2asrv/reqctx.go b/a2asrv/reqctx.go index b532b4d1..0be4e2ea 100644 --- a/a2asrv/reqctx.go +++ b/a2asrv/reqctx.go @@ -1,7 +1,22 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package a2asrv import ( "context" + "github.com/a2aproject/a2a-go/a2a" ) diff --git a/a2asrv/tasks.go b/a2asrv/tasks.go index daaf42ce..875671f2 100644 --- a/a2asrv/tasks.go +++ b/a2asrv/tasks.go @@ -1,7 +1,22 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package a2asrv import ( "context" + "github.com/a2aproject/a2a-go/a2a" ) diff --git a/internal/events/queue.go b/internal/events/queue.go index 817633fb..b55c7d4d 100644 --- a/internal/events/queue.go +++ b/internal/events/queue.go @@ -1,3 +1,17 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package events type InMemoryQueueManager struct{} diff --git a/internal/push/sender.go b/internal/push/sender.go index ef816f95..4943ceb7 100644 --- a/internal/push/sender.go +++ b/internal/push/sender.go @@ -1,3 +1,17 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package push type HTTPPushSender struct{} diff --git a/internal/push/store.go b/internal/push/store.go index 73dbed67..9230d3e0 100644 --- a/internal/push/store.go +++ b/internal/push/store.go @@ -1,3 +1,17 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package push type InMemoryPushConfigStore struct{} diff --git a/internal/task/store.go b/internal/task/store.go index be143ff3..19a52c4b 100644 --- a/internal/task/store.go +++ b/internal/task/store.go @@ -1,3 +1,17 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package task type InMemoryTaskStore struct{} From acebe1da4796d48f32a9aea9d61c30ef641cef80 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Thu, 7 Aug 2025 14:41:47 +0000 Subject: [PATCH 17/23] shorten method name --- a2asrv/handler.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/a2asrv/handler.go b/a2asrv/handler.go index fff0623d..b4ee702c 100644 --- a/a2asrv/handler.go +++ b/a2asrv/handler.go @@ -21,22 +21,22 @@ import ( "github.com/a2aproject/a2a-go/a2a" ) -type RequestHandler interface { - OnHandleGetTask(ctx context.Context, query a2a.TaskQueryParams) (a2a.Task, error) +type Requestr interface { + OnGetTask(ctx context.Context, query a2a.TaskQueryParams) (a2a.Task, error) - OnHandleCancelTask(ctx context.Context, id a2a.TaskIDParams) (a2a.Task, error) + OnCancelTask(ctx context.Context, id a2a.TaskIDParams) (a2a.Task, error) - OnHandleSendMessage(ctx context.Context, message a2a.MessageSendParams) (a2a.SendMessageResult, error) + OnSendMessage(ctx context.Context, message a2a.MessageSendParams) (a2a.SendMessageResult, error) - OnHandleResubscribeToTask(ctx context.Context, id a2a.TaskIDParams) iter.Seq2[a2a.Event, error] + OnResubscribeToTask(ctx context.Context, id a2a.TaskIDParams) iter.Seq2[a2a.Event, error] - OnHandleSendMessageStream(ctx context.Context, message a2a.MessageSendParams) iter.Seq2[a2a.Event, error] + OnSendMessageStream(ctx context.Context, message a2a.MessageSendParams) iter.Seq2[a2a.Event, error] - OnHandleGetTaskPushConfig(ctx context.Context, params a2a.GetTaskPushConfigParams) (a2a.TaskPushConfig, error) + OnGetTaskPushConfig(ctx context.Context, params a2a.GetTaskPushConfigParams) (a2a.TaskPushConfig, error) - OnHandleListTaskPushConfig(ctx context.Context, params a2a.ListTaskPushConfigParams) ([]a2a.TaskPushConfig, error) + OnListTaskPushConfig(ctx context.Context, params a2a.ListTaskPushConfigParams) ([]a2a.TaskPushConfig, error) - OnHandleSetTaskPushConfig(ctx context.Context, params a2a.TaskPushConfig) (a2a.TaskPushConfig, error) + OnSetTaskPushConfig(ctx context.Context, params a2a.TaskPushConfig) (a2a.TaskPushConfig, error) - OnHandleDeleteTaskPushConfig(ctx context.Context, params a2a.DeleteTaskPushConfigParams) error + OnDeleteTaskPushConfig(ctx context.Context, params a2a.DeleteTaskPushConfigParams) error } From 4e4cf0ea4fe23552856a61db7d299f7387ed6dc5 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Thu, 7 Aug 2025 14:44:44 +0000 Subject: [PATCH 18/23] alphabetic sorting --- a2asrv/events.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/a2asrv/events.go b/a2asrv/events.go index 80809a7d..82ec4bac 100644 --- a/a2asrv/events.go +++ b/a2asrv/events.go @@ -20,17 +20,17 @@ import ( "github.com/a2aproject/a2a-go/a2a" ) -type EventWriter interface { - Write(ctx context.Context, event a2a.Event) error -} - type EventReader interface { Read(ctx context.Context) (a2a.Event, error) } +type EventWriter interface { + Write(ctx context.Context, event a2a.Event) error +} + type EventQueue interface { - EventWriter EventReader + EventWriter Close() } From 3280481817737e0db8fafa9804a73fd50c16ef5b Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Fri, 8 Aug 2025 07:40:51 +0000 Subject: [PATCH 19/23] typo fix --- a2asrv/handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/a2asrv/handler.go b/a2asrv/handler.go index b4ee702c..45011171 100644 --- a/a2asrv/handler.go +++ b/a2asrv/handler.go @@ -21,7 +21,7 @@ import ( "github.com/a2aproject/a2a-go/a2a" ) -type Requestr interface { +type RequestHandler interface { OnGetTask(ctx context.Context, query a2a.TaskQueryParams) (a2a.Task, error) OnCancelTask(ctx context.Context, id a2a.TaskIDParams) (a2a.Task, error) From bd3d98e8e9a2f781c324d90ad6ce464cb2d83be6 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Fri, 8 Aug 2025 12:56:41 +0000 Subject: [PATCH 20/23] added missing doc comments, resolved minor interface inconsistencies, added AgentExtendedCardProducer interface --- a2a/errors.go | 11 +++++++++++ a2a/push.go | 3 +-- a2asrv/agent.go | 28 ++++++++++++++++++++++++++-- a2asrv/events.go | 14 ++++++++++++++ a2asrv/handler.go | 10 ++++++++++ a2asrv/reqctx.go | 17 +++++++++++++---- a2asrv/tasks.go | 16 +++++++++++++++- 7 files changed, 90 insertions(+), 9 deletions(-) diff --git a/a2a/errors.go b/a2a/errors.go index a6700dfd..67056b35 100644 --- a/a2a/errors.go +++ b/a2a/errors.go @@ -17,19 +17,30 @@ package a2a import "errors" var ( + // ErrTaskNotFound indicates that a task with the provided ID was not found. ErrTaskNotFound = errors.New("task not found") + // ErrTaskNotCancelable indicates that the task was in a state where it could not be cancelled. ErrTaskNotCancelable = errors.New("task cannot be canceled") + // ErrPushNotificationNotSupported indicates that the agent does not support push notifications. ErrPushNotificationNotSupported = errors.New("push notification not supported") + // ErrUnsupportedOperation indicates that the requested operation is not supported by the agent. ErrUnsupportedOperation = errors.New("this operation is not supported") + // ErrUnsupportedContentType indicates an incompatibility between the requested + // content types and the agent's capabilities. ErrUnsupportedContentType = errors.New("incompatible content types") + // ErrInvalidAgentResponse indicates that the agent returned a response that + // does not conform to the specification for the current method. ErrInvalidAgentResponse = errors.New("invalid agent response") + // ErrInvalidRequest indicates that the received request was invalid. ErrInvalidRequest = errors.New("invalid request") + // ErrAuthenticatedExtendedCardNotConfigured indicates that the agent does not have an Authenticated + // Extended Card configured. ErrAuthenticatedExtendedCardNotConfigured = errors.New("extended card not configured") ) diff --git a/a2a/push.go b/a2a/push.go index 2e9931c0..4528fa77 100644 --- a/a2a/push.go +++ b/a2a/push.go @@ -23,8 +23,7 @@ type GetTaskPushConfigParams struct { ConfigID *string } -// Defines parameters for listing all push notification configurations associated -// with a task. +// Defines parameters for listing all push notification configurations associated with a task. type ListTaskPushConfigParams struct { // The unique identifier of the task. TaskID TaskID diff --git a/a2asrv/agent.go b/a2asrv/agent.go index d723bb5d..d3b0a3f1 100644 --- a/a2asrv/agent.go +++ b/a2asrv/agent.go @@ -20,12 +20,36 @@ import ( "github.com/a2aproject/a2a-go/a2a" ) +// AgentExecutor implementations translate agent outputs to A2A events. type AgentExecutor interface { - Execute(ctx context.Context, reqCtx RequestContext, queue EventQueue) error + // Execute invokes an agent with the provided context and translates agent outputs + // into A2A events writing them to the provided event queue. + // + // Returns an error if agent invocation failed. + Execute(ctx context.Context, reqCtx RequestContext, queue EventWriter) error - Cancel(ctx context.Context, reqCtx RequestContext, queue EventQueue) error + // Cancel requests the agent to stop processing an ongoing task. + // + // The agent should attempt to gracefully stop the task identified by the + // task ID in the request context and publish a TaskStatusUpdateEvent with + // state TaskStateCanceled to the event queue. + // + // Returns an error if the cancellation request cannot be processed. + Cancel(ctx context.Context, reqCtx RequestContext, queue EventWriter) error } +// AgentCardProducer creates an AgentCard instances used for agent discovery and capability negotiation. type AgentCardProducer interface { + // Card returns a self-describing manifest for an agent. It provides essential + // metadata including the agent's identity, capabilities, skills, supported + // communication methods, and security requirements and is publicly available. Card() a2a.AgentCard } + +// ExtendedAgentCardProducer can create both public agent cards and cards available to authenticated users only. +type ExtendedAgentCardProducer interface { + AgentCardProducer + + // ExtendedCard returns a manifest for an agent which is only available to authenticated users. + ExtendedCard() a2a.AgentCard +} diff --git a/a2asrv/events.go b/a2asrv/events.go index 82ec4bac..7f367766 100644 --- a/a2asrv/events.go +++ b/a2asrv/events.go @@ -20,23 +20,37 @@ import ( "github.com/a2aproject/a2a-go/a2a" ) +// EventReader defines the interface for reading events from a queue. +// A2A server stack reads events written by AgentExecutor. type EventReader interface { + // Read dequeues an event or blocks if the queue is empty. Read(ctx context.Context) (a2a.Event, error) } +// EventWriter defines the interface for writing events to a queue. +// AgentExecutor translates agent responses to Messages, Tasks or Task update events. type EventWriter interface { + // Write enqueues an event or blocks if a bounded queue is full. Write(ctx context.Context, event a2a.Event) error } +// EventQueue defines the interface for publishing and consuming +// events generated during agent execution. type EventQueue interface { EventReader EventWriter + // Close shuts down a connection to the queue. Close() } +// EventQueueManager manages event queues on a per-task basis. +// It provides lifecycle management for task-specific event queues, +// enabling multiple clients to attach to the same task's event stream. type EventQueueManager interface { + // GetOrCreate returns an existing queue if one exists, or creates a new one. GetOrCreate(ctx context.Context, taskId a2a.TaskID) (EventQueue, error) + // Destroy closes the queue for the specified task and frees all associates resources. Destroy(ctx context.Context, taskId a2a.TaskID) error } diff --git a/a2asrv/handler.go b/a2asrv/handler.go index 45011171..41b55ca0 100644 --- a/a2asrv/handler.go +++ b/a2asrv/handler.go @@ -21,22 +21,32 @@ import ( "github.com/a2aproject/a2a-go/a2a" ) +// RequestHandler defines a transport-agnostic interface for handling incoming A2A requests. type RequestHandler interface { + // OnGetTask handles the 'tasks/get' protocol method. OnGetTask(ctx context.Context, query a2a.TaskQueryParams) (a2a.Task, error) + // OnCancelTask handles the 'tasks/cancel' protocol method. OnCancelTask(ctx context.Context, id a2a.TaskIDParams) (a2a.Task, error) + // OnSendMessage handles the 'message/send' protocol method (non-streaming). OnSendMessage(ctx context.Context, message a2a.MessageSendParams) (a2a.SendMessageResult, error) + // OnResubscribeToTask handles the `tasks/resubscribe` protocol method. OnResubscribeToTask(ctx context.Context, id a2a.TaskIDParams) iter.Seq2[a2a.Event, error] + // OnMessageSendStream handles the 'message/stream' protocol method (streaming). OnSendMessageStream(ctx context.Context, message a2a.MessageSendParams) iter.Seq2[a2a.Event, error] + // OnGetTaskPushNotificationConfig handles the `tasks/pushNotificationConfig/get` protocol method. OnGetTaskPushConfig(ctx context.Context, params a2a.GetTaskPushConfigParams) (a2a.TaskPushConfig, error) + // OnListTaskPushNotificationConfig handles the `tasks/pushNotificationConfig/list` protocol method. OnListTaskPushConfig(ctx context.Context, params a2a.ListTaskPushConfigParams) ([]a2a.TaskPushConfig, error) + // OnSetTaskPushConfig handles the `tasks/pushNotificationConfig/set` protocol method. OnSetTaskPushConfig(ctx context.Context, params a2a.TaskPushConfig) (a2a.TaskPushConfig, error) + // OnDeleteTaskPushNotificationConfig handles the `tasks/pushNotificationConfig/delete` protocol method. OnDeleteTaskPushConfig(ctx context.Context, params a2a.DeleteTaskPushConfigParams) error } diff --git a/a2asrv/reqctx.go b/a2asrv/reqctx.go index 0be4e2ea..02e5adb2 100644 --- a/a2asrv/reqctx.go +++ b/a2asrv/reqctx.go @@ -20,14 +20,23 @@ import ( "github.com/a2aproject/a2a-go/a2a" ) +// RequestContextBuilder defines an extension point for constructing request contexts +// that contain the information needed by AgentExecutor implementations to process incoming requests. type RequestContextBuilder interface { + // Build constructs a RequestContext from the provided parameters. Build(ctx context.Context, p a2a.MessageSendParams, t *a2a.Task) RequestContext } +// RequestContext provides information about an incoming A2A request to AgentExecutor. type RequestContext struct { - Request a2a.MessageSendParams - TaskID a2a.TaskID - Task *a2a.Task + // Request which triggered the execution. + Request a2a.MessageSendParams + // TaskID is an ID of the task or a newly generated UUIDv4 in case Message did not reference any Task. + TaskID a2a.TaskID + // Task is present if request message specified a TaskID. + Task *a2a.Task + // RelatedTasks can be present when Message includes Task references and RequestContextBuilder is configured to load them. RelatedTasks []a2a.Task - ContextID string + // ContextID is a server-generated identifier for maintaining context across multiple related tasks or interactions. Matches the Task ContextID. + ContextID string } diff --git a/a2asrv/tasks.go b/a2asrv/tasks.go index 875671f2..c39f6c28 100644 --- a/a2asrv/tasks.go +++ b/a2asrv/tasks.go @@ -20,20 +20,34 @@ import ( "github.com/a2aproject/a2a-go/a2a" ) +// PushNotifier defines the interface for sending push notifications +// about task state changes to external endpoints. type PushNotifier interface { + // SendPush sends a push notification containing the latest task state. SendPush(ctx context.Context, task a2a.Task) error } +// PushConfigStore manages push notification configurations for tasks. type PushConfigStore interface { + // Save creates or updates a push notification configuration for a task. + // PushConfig has an ID and a Task can have multiple associated configurations. Save(ctx context.Context, taskId a2a.TaskID, config a2a.PushConfig) error + // Get retrieves all registered push configurations for a Task. Get(ctx context.Context, taskId a2a.TaskID) ([]a2a.PushConfig, error) - Delete(ctx context.Context, taskId a2a.TaskID) error + // Delete removes a push configuration registered for a Task with the given configID. + Delete(ctx context.Context, taskId a2a.TaskID, configID string) error + + // DeleteAll removes all registered push configurations of a Task. + DeleteAll(ctx context.Context, taskId a2a.TaskID) error } +// TaskStore provides storage for A2A tasks. type TaskStore interface { + // Save stores a task. Save(ctx context.Context, task a2a.Task) error + // Get retrieves a task by ID. Get(ctx context.Context, taskId a2a.TaskID) (a2a.Task, error) } From a6633390932428791c2908ff487764021376af9c Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Fri, 8 Aug 2025 12:59:06 +0000 Subject: [PATCH 21/23] expose proto generated files as a2apb package --- {grpc => a2apb}/a2a.pb.go | 6 +++--- {grpc => a2apb}/a2a_grpc.pb.go | 2 +- buf.gen.yaml | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) rename {grpc => a2apb}/a2a.pb.go (99%) rename {grpc => a2apb}/a2a_grpc.pb.go (99%) diff --git a/grpc/a2a.pb.go b/a2apb/a2a.pb.go similarity index 99% rename from grpc/a2a.pb.go rename to a2apb/a2a.pb.go index 8dc9e385..1b6d7658 100644 --- a/grpc/a2a.pb.go +++ b/a2apb/a2a.pb.go @@ -6,7 +6,7 @@ // protoc (unknown) // source: a2a.proto -package grpc +package a2apb import ( _ "google.golang.org/genproto/googleapis/api/annotations" @@ -3579,9 +3579,9 @@ const file_a2a_proto_rawDesc = "" + "\x1eListTaskPushNotificationConfig\x12-.a2a.v1.ListTaskPushNotificationConfigRequest\x1a..a2a.v1.ListTaskPushNotificationConfigResponse\"=\xdaA\x06parent\x82\xd3\xe4\x93\x02.\x12,/v1/{parent=tasks/*}/pushNotificationConfigs\x12P\n" + "\fGetAgentCard\x12\x1b.a2a.v1.GetAgentCardRequest\x1a\x11.a2a.v1.AgentCard\"\x10\x82\xd3\xe4\x93\x02\n" + "\x12\b/v1/card\x12\xa8\x01\n" + - " DeleteTaskPushNotificationConfig\x12/.a2a.v1.DeleteTaskPushNotificationConfigRequest\x1a\x16.google.protobuf.Empty\";\xdaA\x04name\x82\xd3\xe4\x93\x02.*,/v1/{name=tasks/*/pushNotificationConfigs/*}Bo\n" + + " DeleteTaskPushNotificationConfig\x12/.a2a.v1.DeleteTaskPushNotificationConfigRequest\x1a\x16.google.protobuf.Empty\";\xdaA\x04name\x82\xd3\xe4\x93\x02.*,/v1/{name=tasks/*/pushNotificationConfigs/*}Bs\n" + "\n" + - "com.a2a.v1B\bA2aProtoP\x01Z\x1egithub.com/a2aproject/a2a/grpc\xa2\x02\x03AXX\xaa\x02\x06A2a.V1\xca\x02\x06A2a\\V1\xe2\x02\x12A2a\\V1\\GPBMetadata\xea\x02\aA2a::V1b\x06proto3" + "com.a2a.v1B\bA2aProtoP\x01Z\"github.com/a2aproject/a2a-go/a2apb\xa2\x02\x03AXX\xaa\x02\x06A2a.V1\xca\x02\x06A2a\\V1\xe2\x02\x12A2a\\V1\\GPBMetadata\xea\x02\aA2a::V1b\x06proto3" var ( file_a2a_proto_rawDescOnce sync.Once diff --git a/grpc/a2a_grpc.pb.go b/a2apb/a2a_grpc.pb.go similarity index 99% rename from grpc/a2a_grpc.pb.go rename to a2apb/a2a_grpc.pb.go index b1695cfb..09b461ac 100644 --- a/grpc/a2a_grpc.pb.go +++ b/a2apb/a2a_grpc.pb.go @@ -6,7 +6,7 @@ // - protoc (unknown) // source: a2a.proto -package grpc +package a2apb import ( context "context" diff --git a/buf.gen.yaml b/buf.gen.yaml index 466f107a..cfd67fe2 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -17,15 +17,15 @@ managed: override: - file_option: go_package path: a2a.proto - value: github.com/a2aproject/a2a/grpc + value: github.com/a2aproject/a2a-go/a2apb plugins: - remote: buf.build/protocolbuffers/go - out: grpc + out: a2apb opt: - paths=source_relative - remote: buf.build/grpc/go - out: grpc + out: a2apb opt: - paths=source_relative \ No newline at end of file From e1aee8876ae97e0584a1f8b2ff267e5b4dfb4695 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Fri, 8 Aug 2025 13:44:40 +0000 Subject: [PATCH 22/23] added doc.go files --- a2a/doc.go | 19 +++++++++++++++++++ a2apb/doc.go | 17 +++++++++++++++++ a2asrv/doc.go | 20 ++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 a2a/doc.go create mode 100644 a2apb/doc.go create mode 100644 a2asrv/doc.go diff --git a/a2a/doc.go b/a2a/doc.go new file mode 100644 index 00000000..5642398a --- /dev/null +++ b/a2a/doc.go @@ -0,0 +1,19 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package a2a contains core types and constants from the A2A protocol +// shared by client and server implementations. +// +// These types implement the A2A specification and are transport-agnostic. +package a2a diff --git a/a2apb/doc.go b/a2apb/doc.go new file mode 100644 index 00000000..2e3e8365 --- /dev/null +++ b/a2apb/doc.go @@ -0,0 +1,17 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package a2apb contains types and interfaces generated from published +// official A2A .proto specification. +package a2apb diff --git a/a2asrv/doc.go b/a2asrv/doc.go new file mode 100644 index 00000000..ec6b06dd --- /dev/null +++ b/a2asrv/doc.go @@ -0,0 +1,20 @@ +// Copyright 2025 The A2A Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package a2asrv provides a configurable A2A protocol server implementation. +// +// The server can be configured with custom implementations of core interfaces +// like TaskStore, AgentExecutor, and PushNotifier to support different +// deployment scenarios and business requirements. +package a2asrv From 38543db95fb81a205a6057924d704ed65979be41 Mon Sep 17 00:00:00 2001 From: Yaroslav Shevchuk Date: Tue, 12 Aug 2025 09:21:46 +0000 Subject: [PATCH 23/23] rename Uri -> URI --- a2a/agent.go | 2 +- a2a/core.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/a2a/agent.go b/a2a/agent.go index eb4d8e23..425aa1f5 100644 --- a/a2a/agent.go +++ b/a2a/agent.go @@ -152,7 +152,7 @@ type AgentExtension struct { Required *bool // The unique URI identifying the extension. - Uri string + URI string } // Declares a combination of a target URL and a transport protocol for interacting diff --git a/a2a/core.go b/a2a/core.go index 3a9a5556..c6664a94 100644 --- a/a2a/core.go +++ b/a2a/core.go @@ -261,7 +261,7 @@ type FilePartFile struct { Name *string // A URL pointing to the file's content. - Uri string + URI string } // Represents a file with its content provided directly as a base64-encoded string. @@ -277,7 +277,7 @@ type FileWithBytes struct { } // Represents a file with its content located at a specific URI. -type FileWithUri struct { +type FileWithURI struct { // The MIME type of the file (e.g., "application/pdf"). MimeType *string @@ -285,7 +285,7 @@ type FileWithUri struct { Name *string // A URL pointing to the file's content. - Uri string + URI string } // Requests