|
| 1 | +// Copyright 2025 The A2A Authors |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package a2a |
| 16 | + |
| 17 | +// Defines optional capabilities supported by an agent. |
| 18 | +type AgentCapabilities struct { |
| 19 | + // A list of protocol extensions supported by the agent. |
| 20 | + Extensions []AgentExtension |
| 21 | + |
| 22 | + // Indicates if the agent supports sending push notifications for asynchronous |
| 23 | + // task updates. |
| 24 | + PushNotifications *bool |
| 25 | + |
| 26 | + // Indicates if the agent provides a history of state transitions for a task. |
| 27 | + StateTransitionHistory *bool |
| 28 | + |
| 29 | + // Indicates if the agent supports Server-Sent Events (SSE) for streaming |
| 30 | + // responses. |
| 31 | + Streaming *bool |
| 32 | +} |
| 33 | + |
| 34 | +// The AgentCard is a self-describing manifest for an agent. It provides essential |
| 35 | +// metadata including the agent's identity, capabilities, skills, supported |
| 36 | +// communication methods, and security requirements. |
| 37 | +type AgentCard struct { |
| 38 | + // A list of additional supported interfaces (transport and URL combinations). |
| 39 | + // This allows agents to expose multiple transports, potentially at different |
| 40 | + // URLs. |
| 41 | + // |
| 42 | + // Best practices: |
| 43 | + // - SHOULD include all supported transports for completeness |
| 44 | + // - SHOULD include an entry matching the main 'url' and 'preferredTransport' |
| 45 | + // - MAY reuse URLs if multiple transports are available at the same endpoint |
| 46 | + // - MUST accurately declare the transport available at each URL |
| 47 | + // |
| 48 | + // Clients can select any interface from this list based on their transport |
| 49 | + // capabilities |
| 50 | + // and preferences. This enables transport negotiation and fallback scenarios. |
| 51 | + AdditionalInterfaces []AgentInterface |
| 52 | + |
| 53 | + // A declaration of optional capabilities supported by the agent. |
| 54 | + Capabilities AgentCapabilities |
| 55 | + |
| 56 | + // Default set of supported input MIME types for all skills, which can be |
| 57 | + // overridden on a per-skill basis. |
| 58 | + DefaultInputModes []string |
| 59 | + |
| 60 | + // Default set of supported output MIME types for all skills, which can be |
| 61 | + // overridden on a per-skill basis. |
| 62 | + DefaultOutputModes []string |
| 63 | + |
| 64 | + // A human-readable description of the agent, assisting users and other agents |
| 65 | + // in understanding its purpose. |
| 66 | + Description string |
| 67 | + |
| 68 | + // An optional URL to the agent's documentation. |
| 69 | + DocumentationURL *string |
| 70 | + |
| 71 | + // An optional URL to an icon for the agent. |
| 72 | + IconURL *string |
| 73 | + |
| 74 | + // A human-readable name for the agent. |
| 75 | + Name string |
| 76 | + |
| 77 | + // The transport protocol for the preferred endpoint (the main 'url' field). |
| 78 | + // If not specified, defaults to 'JSONRPC'. |
| 79 | + // |
| 80 | + // IMPORTANT: The transport specified here MUST be available at the main 'url'. |
| 81 | + // This creates a binding between the main URL and its supported transport |
| 82 | + // protocol. |
| 83 | + // Clients should prefer this transport and URL combination when both are |
| 84 | + // supported. |
| 85 | + PreferredTransport TransportProtocol |
| 86 | + |
| 87 | + // The version of the A2A protocol this agent supports. |
| 88 | + ProtocolVersion string |
| 89 | + |
| 90 | + // Information about the agent's service provider. |
| 91 | + Provider *AgentProvider |
| 92 | + |
| 93 | + // A list of security requirement objects that apply to all agent interactions. |
| 94 | + // Each object |
| 95 | + // lists security schemes that can be used. Follows the OpenAPI 3.0 Security |
| 96 | + // Requirement Object. |
| 97 | + // This list can be seen as an OR of ANDs. Each object in the list describes one |
| 98 | + // possible |
| 99 | + // set of security requirements that must be present on a request. This allows |
| 100 | + // specifying, |
| 101 | + // for example, "callers must either use OAuth OR an API Key AND mTLS." |
| 102 | + Security []map[string][]string |
| 103 | + |
| 104 | + // A declaration of the security schemes available to authorize requests. The key |
| 105 | + // is the |
| 106 | + // scheme name. Follows the OpenAPI 3.0 Security Scheme Object. |
| 107 | + SecuritySchemes map[string]any |
| 108 | + |
| 109 | + // JSON Web Signatures computed for this AgentCard. |
| 110 | + Signatures []AgentCardSignature |
| 111 | + |
| 112 | + // The set of skills, or distinct capabilities, that the agent can perform. |
| 113 | + Skills []AgentSkill |
| 114 | + |
| 115 | + // If true, the agent can provide an extended agent card with additional details |
| 116 | + // to authenticated users. Defaults to false. |
| 117 | + SupportsAuthenticatedExtendedCard *bool |
| 118 | + |
| 119 | + // The preferred endpoint URL for interacting with the agent. |
| 120 | + // This URL MUST support the transport specified by 'preferredTransport'. |
| 121 | + URL string |
| 122 | + |
| 123 | + // The agent's own version number. The format is defined by the provider. |
| 124 | + Version string |
| 125 | +} |
| 126 | + |
| 127 | +// AgentCardSignature represents a JWS signature of an AgentCard. |
| 128 | +// This follows the JSON format of an RFC 7515 JSON Web Signature (JWS). |
| 129 | +type AgentCardSignature struct { |
| 130 | + // The unprotected JWS header values. |
| 131 | + Header map[string]any |
| 132 | + |
| 133 | + // The protected JWS header for the signature. This is a Base64url-encoded |
| 134 | + // JSON object, as per RFC 7515. |
| 135 | + Protected string |
| 136 | + |
| 137 | + // The computed signature, Base64url-encoded. |
| 138 | + Signature string |
| 139 | +} |
| 140 | + |
| 141 | +// A declaration of a protocol extension supported by an Agent. |
| 142 | +type AgentExtension struct { |
| 143 | + // A human-readable description of how this agent uses the extension. |
| 144 | + Description *string |
| 145 | + |
| 146 | + // Optional, extension-specific configuration parameters. |
| 147 | + Params map[string]any |
| 148 | + |
| 149 | + // If true, the client must understand and comply with the extension's |
| 150 | + // requirements |
| 151 | + // to interact with the agent. |
| 152 | + Required *bool |
| 153 | + |
| 154 | + // The unique URI identifying the extension. |
| 155 | + URI string |
| 156 | +} |
| 157 | + |
| 158 | +// Declares a combination of a target URL and a transport protocol for interacting |
| 159 | +// with the agent. |
| 160 | +// This allows agents to expose the same functionality over multiple transport |
| 161 | +// mechanisms. |
| 162 | +type AgentInterface struct { |
| 163 | + // The transport protocol supported at this URL. |
| 164 | + Transport string |
| 165 | + |
| 166 | + // The URL where this interface is available. Must be a valid absolute HTTPS URL |
| 167 | + // in production. |
| 168 | + URL string |
| 169 | +} |
| 170 | + |
| 171 | +// Represents the service provider of an agent. |
| 172 | +type AgentProvider struct { |
| 173 | + // The name of the agent provider's organization. |
| 174 | + Org string |
| 175 | + |
| 176 | + // A URL for the agent provider's website or relevant documentation. |
| 177 | + URL string |
| 178 | +} |
| 179 | + |
| 180 | +// Represents a distinct capability or function that an agent can perform. |
| 181 | +type AgentSkill struct { |
| 182 | + // A detailed description of the skill, intended to help clients or users |
| 183 | + // understand its purpose and functionality. |
| 184 | + Description string |
| 185 | + |
| 186 | + // Example prompts or scenarios that this skill can handle. Provides a hint to |
| 187 | + // the client on how to use the skill. |
| 188 | + Examples []string |
| 189 | + |
| 190 | + // A unique identifier for the agent's skill. |
| 191 | + ID string |
| 192 | + |
| 193 | + // The set of supported input MIME types for this skill, overriding the agent's |
| 194 | + // defaults. |
| 195 | + InputModes []string |
| 196 | + |
| 197 | + // A human-readable name for the skill. |
| 198 | + Name string |
| 199 | + |
| 200 | + // The set of supported output MIME types for this skill, overriding the agent's |
| 201 | + // defaults. |
| 202 | + OutputModes []string |
| 203 | + |
| 204 | + // Security schemes necessary for the agent to leverage this skill. |
| 205 | + // As in the overall AgentCard.security, this list represents a logical OR of |
| 206 | + // security |
| 207 | + // requirement objects. Each object is a set of security schemes that must be used |
| 208 | + // together |
| 209 | + // (a logical AND). |
| 210 | + Security []map[string][]string |
| 211 | + |
| 212 | + // A set of keywords describing the skill's capabilities. |
| 213 | + Tags []string |
| 214 | +} |
| 215 | + |
| 216 | +type TransportProtocol string |
| 217 | + |
| 218 | +const ( |
| 219 | + TransportProtocolJSONRPC TransportProtocol = "JSONRPC" |
| 220 | + TransportProtocolGRPC TransportProtocol = "GRPC" |
| 221 | + TransportProtocolHTTPJSON TransportProtocol = "HTTP+JSON" |
| 222 | +) |
0 commit comments