a2a 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.agent-docs/ROADMAP.md +423 -0
  3. data/.agent-docs/index.md +124 -0
  4. data/.agent-docs/llms.txt +318 -0
  5. data/.agent-docs/specification/json.json +2575 -0
  6. data/.agent-docs/specification.md +1924 -0
  7. data/.agent-docs/topics/a2a-and-mcp.md +132 -0
  8. data/.agent-docs/topics/agent-discovery.md +96 -0
  9. data/.agent-docs/topics/enterprise-ready.md +139 -0
  10. data/.agent-docs/topics/extensions.md +260 -0
  11. data/.agent-docs/topics/key-concepts.md +99 -0
  12. data/.agent-docs/topics/life-of-a-task.md +255 -0
  13. data/.agent-docs/topics/streaming-and-async.md +111 -0
  14. data/.agent-docs/topics/what-is-a2a.md +218 -0
  15. data/.agent-docs/tutorials/index.md +31 -0
  16. data/.agent-docs/tutorials/python/1-introduction.md +32 -0
  17. data/.agent-docs/tutorials/python/2-setup.md +55 -0
  18. data/.agent-docs/tutorials/python/3-agent-skills-and-card.md +48 -0
  19. data/.agent-docs/tutorials/python/4-agent-executor.md +57 -0
  20. data/.agent-docs/tutorials/python/5-start-server.md +55 -0
  21. data/.agent-docs/tutorials/python/6-interact-with-server.md +95 -0
  22. data/.agent-docs/tutorials/python/7-streaming-and-multiturn.md +97 -0
  23. data/.agent-docs/tutorials/python/8-next-steps.md +40 -0
  24. data/.agent-docs/types.ts +1544 -0
  25. data/.agent-docs/types_mapping.md +196 -0
  26. data/.claude/commands/gemfile/update.md +52 -0
  27. data/.claude/settings.local.json +23 -0
  28. data/.tool-versions +1 -1
  29. data/CHANGELOG.md +68 -1
  30. data/CLAUDE.md +98 -0
  31. data/README.md +20 -14
  32. data/Rakefile +1 -3
  33. data/WARP.md +115 -0
  34. data/lib/a2a/extensions/json_deserialization.rb +1 -3
  35. data/lib/a2a/types/agent_capabilities.rb +3 -0
  36. data/lib/a2a/types/agent_card.rb +49 -17
  37. data/lib/a2a/types/agent_card_signature.rb +17 -0
  38. data/lib/a2a/types/agent_extension.rb +19 -0
  39. data/lib/a2a/types/agent_interface.rb +13 -0
  40. data/lib/a2a/types/agent_provider.rb +2 -2
  41. data/lib/a2a/types/agent_skill.rb +11 -4
  42. data/lib/a2a/types/api_key_security_scheme.rb +15 -0
  43. data/lib/a2a/types/artifact.rb +10 -15
  44. data/lib/a2a/types/authenticated_extended_card_not_configured_error.rb +43 -0
  45. data/lib/a2a/types/authorization_code_oauth_flow.rb +22 -0
  46. data/lib/a2a/types/cancel_task_request.rb +5 -2
  47. data/lib/a2a/types/cancel_task_response.rb +3 -3
  48. data/lib/a2a/types/client_credentials_oauth_flow.rb +16 -0
  49. data/lib/a2a/types/content_type_not_supported_error.rb +42 -0
  50. data/lib/a2a/types/data_part.rb +5 -8
  51. data/lib/a2a/types/delete_task_push_notification_config_params.rb +9 -0
  52. data/lib/a2a/types/delete_task_push_notification_config_request.rb +18 -0
  53. data/lib/a2a/types/delete_task_push_notification_config_response.rb +13 -0
  54. data/lib/a2a/types/error.rb +19 -0
  55. data/lib/a2a/types/error_codes.rb +6 -0
  56. data/lib/a2a/types/file_base.rb +12 -0
  57. data/lib/a2a/types/file_part.rb +7 -9
  58. data/lib/a2a/types/file_with_bytes.rb +9 -0
  59. data/lib/a2a/types/file_with_uri.rb +9 -0
  60. data/lib/a2a/types/get_authenticated_extended_card_request.rb +15 -0
  61. data/lib/a2a/types/get_authenticated_extended_card_response.rb +13 -0
  62. data/lib/a2a/types/get_task_push_notification_config_params.rb +9 -0
  63. data/lib/a2a/types/get_task_push_notification_config_request.rb +21 -0
  64. data/lib/a2a/types/get_task_push_notification_request.rb +5 -2
  65. data/lib/a2a/types/get_task_push_notification_response.rb +4 -4
  66. data/lib/a2a/types/get_task_request.rb +5 -2
  67. data/lib/a2a/types/get_task_response.rb +3 -3
  68. data/lib/a2a/types/http_auth_security_scheme.rb +18 -0
  69. data/lib/a2a/types/implicit_oauth_flow.rb +16 -0
  70. data/lib/a2a/types/invalid_agent_response_error.rb +41 -0
  71. data/lib/a2a/types/list_task_push_notification_config_params.rb +8 -0
  72. data/lib/a2a/types/list_task_push_notification_config_request.rb +18 -0
  73. data/lib/a2a/types/list_task_push_notification_config_response.rb +13 -0
  74. data/lib/a2a/types/message.rb +24 -4
  75. data/lib/a2a/types/message_send_configuration.rb +20 -0
  76. data/lib/a2a/types/message_send_params.rb +16 -0
  77. data/lib/a2a/types/mutual_tls_security_scheme.rb +9 -0
  78. data/lib/a2a/types/oauth2_security_scheme.rb +16 -0
  79. data/lib/a2a/types/oauth_flows.rb +20 -0
  80. data/lib/a2a/types/openid_connect_security_scheme.rb +12 -0
  81. data/lib/a2a/types/part.rb +2 -1
  82. data/lib/a2a/types/part_base.rb +9 -0
  83. data/lib/a2a/types/password_oauth_flow.rb +16 -0
  84. data/lib/a2a/types/push_notification_authentication_info.rb +12 -0
  85. data/lib/a2a/types/push_notification_config.rb +11 -6
  86. data/lib/a2a/types/push_notification_not_supported_error.rb +37 -10
  87. data/lib/a2a/types/request.rb +15 -0
  88. data/lib/a2a/types/security_scheme.rb +11 -0
  89. data/lib/a2a/types/security_scheme_base.rb +9 -0
  90. data/lib/a2a/types/send_message_request.rb +18 -0
  91. data/lib/a2a/types/send_message_response.rb +13 -0
  92. data/lib/a2a/types/send_streaming_message_request.rb +18 -0
  93. data/lib/a2a/types/send_streaming_message_response.rb +15 -0
  94. data/lib/a2a/types/set_task_push_notification_config_request.rb +18 -0
  95. data/lib/a2a/types/set_task_push_notification_request.rb +5 -2
  96. data/lib/a2a/types/set_task_push_notification_response.rb +4 -4
  97. data/lib/a2a/types/task.rb +15 -11
  98. data/lib/a2a/types/task_artifact_update_event.rb +18 -7
  99. data/lib/a2a/types/task_not_cancelable_error.rb +37 -10
  100. data/lib/a2a/types/task_not_found_error.rb +37 -10
  101. data/lib/a2a/types/task_resubscription_request.rb +5 -2
  102. data/lib/a2a/types/task_state.rb +2 -1
  103. data/lib/a2a/types/task_status_update_event.rb +13 -6
  104. data/lib/a2a/types/text_part.rb +5 -8
  105. data/lib/a2a/types/transport_protocol.rb +6 -0
  106. data/lib/a2a/types/unsupported_operation_error.rb +37 -10
  107. data/lib/a2a/types.rb +13 -0
  108. data/lib/a2a/version.rb +1 -1
  109. data/lib/a2a.rb +15 -5
  110. metadata +101 -19
  111. data/lib/a2a/types/agent_authentication.rb +0 -13
  112. data/lib/a2a/types/authentication_info.rb +0 -9
  113. data/lib/a2a/types/file_content.rb +0 -18
  114. data/lib/a2a/types/internal_error.rb +0 -15
  115. data/lib/a2a/types/invalid_params_error.rb +0 -15
  116. data/lib/a2a/types/invalid_request_error.rb +0 -15
  117. data/lib/a2a/types/json_parse_error.rb +0 -15
  118. data/lib/a2a/types/jsonrpc_error.rb +0 -15
  119. data/lib/a2a/types/jsonrpc_message.rb +0 -12
  120. data/lib/a2a/types/jsonrpc_request.rb +0 -15
  121. data/lib/a2a/types/jsonrpc_response.rb +0 -12
  122. data/lib/a2a/types/method_not_found_error.rb +0 -15
  123. data/lib/a2a/types/send_task_request.rb +0 -15
  124. data/lib/a2a/types/send_task_response.rb +0 -13
  125. data/lib/a2a/types/send_task_streaming_request.rb +0 -15
  126. data/lib/a2a/types/send_task_streaming_response.rb +0 -15
  127. data/lib/a2a/types/task_send_params.rb +0 -26
@@ -0,0 +1,318 @@
1
+ # A2A (Agent2Agent) Protocol High-Level Summary
2
+
3
+ This project defines and demonstrates the **Agent2Agent (A2A) protocol**, an open standard initiated by Google designed to enable communication and interoperability between disparate AI agent systems. The core goal is to allow agents built on different frameworks (e.g., LangGraph, CrewAI, Google ADK, Genkit) or by different vendors to discover each other's capabilities, negotiate interaction modes (text, forms, files, potentially audio/video later), and collaborate on tasks.
4
+
5
+ The repository provides:
6
+
7
+ 1. **Formal Specification:** A detailed JSON Schema (`specification/json/a2a.json`) defining the structure of A2A messages, including requests, responses, task states, artifacts, and agent metadata (Agent Cards).
8
+ 2. **Core Concepts Documentation (Implied):** Links in the main README suggest documentation covering agent discovery, task lifecycle, artifact exchange, streaming updates, push notifications, and enterprise readiness.
9
+ 3. **Sample Implementations:**
10
+ - **Common Libraries:** Reusable Python (`samples/python/common`) and JavaScript/TypeScript (`samples/js/src`) code for building A2A clients and servers, handling JSON-RPC communication, task management, and potentially authentication.
11
+ - **Example Agents:** Demonstrations of integrating A2A into various agent frameworks:
12
+ - **Python:** LangGraph (currency conversion, streaming), CrewAI (image generation, file artifacts), Google ADK (expense reports, form handling).
13
+ - **JavaScript/TypeScript:** Genkit (movie info via API, code generation with file artifacts).
14
+ - **Example Hosts:** Applications that *consume* A2A services:
15
+ - CLIs in both Python and JS for direct interaction.
16
+ - A Python-based multi-agent orchestrator (using Google ADK) that delegates tasks to other A2A agents.
17
+ 4. **Demo Web Application:** A web UI (`demo/ui`, likely using Mesop) demonstrating multi-agent interactions facilitated by the A2A protocol, including visualization of conversations, tasks, events, and agent discovery. It features a backend service coordinating with the host agent.
18
+
19
+ Key features of the A2A protocol highlighted by the specification and samples include: agent discovery via Agent Cards, standardized task management (send, get, cancel), support for different content types (text, files, structured data) via `Parts` and `Artifacts`, streaming updates for long-running tasks, and mechanisms for push notifications. The project is open source and encourages community contribution.
20
+
21
+ # A2A (Agent2Agent) Protocol
22
+
23
+ ## 1. Overview
24
+
25
+ - **Project Name:** Agent2Agent (A2A) Protocol
26
+ - **Purpose:** An open protocol by Google enabling communication and interoperability between AI agents built on different frameworks or by different vendors.
27
+ - **Core Goal:** Allow agents to discover capabilities, negotiate interaction, and collaborate securely on tasks.
28
+ - **Communication:** Uses JSON-RPC 2.0 over HTTP(S). Supports standard request/response and Server-Sent Events (SSE) for streaming.
29
+ - **Key Components:** Specification (JSON Schema), Common Libraries (Python, JS/TS), Sample Agents (LangGraph, CrewAI, ADK, Genkit), Sample Hosts (CLI, Orchestrator), Demo Web App (Mesop).
30
+
31
+ ## 2. Protocol Specification (`specification/json/a2a.json`)
32
+
33
+ ### 2.1. Core JSON-RPC Structures
34
+
35
+ - **`JSONRPCMessage`:** Base for requests/responses. Contains `jsonrpc: "2.0"` and optional `id`.
36
+ - **`JSONRPCRequest`:** Represents a request.
37
+ - `method`: String identifying the operation (e.g., "tasks/send").
38
+ - `params`: Object or Array containing parameters for the method.
39
+ - `id`: Unique identifier (string/number) for request/response correlation. Omitted/null for notifications.
40
+ - **`JSONRPCResponse`:** Represents a response.
41
+ - `result`: Contains the successful result data (can be `null`). Mutually exclusive with `error`.
42
+ - `error`: Contains an error object if the request failed. Mutually exclusive with `result`.
43
+ - `id`: Must match the corresponding request `id`.
44
+ - **`JSONRPCError`:** Represents an error.
45
+ - `code`: Integer error code.
46
+ - `message`: String description of the error.
47
+ - `data`: Optional additional error details.
48
+
49
+ ### 2.2. Key A2A Data Objects
50
+
51
+ - **`AgentCard`:** Metadata describing an agent. Found typically at `/.well-known/agent-card.json`.
52
+ - `name`: (string) Human-readable name.
53
+ - `description`: (string) Agent description.
54
+ - `url`: (string) Base URL endpoint for the agent's A2A service.
55
+ - `provider`: (`AgentProvider`) Organization details (optional).
56
+ - `version`: (string) Agent/API version.
57
+ - `documentationUrl`: (string) Link to documentation (optional).
58
+ - `capabilities`: (`AgentCapabilities`) Features supported (streaming, push).
59
+ - `securitySchemes`: (Object) Security scheme details for authentication (optional).
60
+ - `security`: (Array) Security requirements for contacting the agent (optional).
61
+ - `defaultInputModes`: (string[]) Default supported input types (e.g., "text/plain", "application/json").
62
+ - `defaultOutputModes`: (string[]) Default supported output types.
63
+ - `skills`: (`AgentSkill[]`) List of specific capabilities.
64
+ - `supportsAuthenticatedExtendedCard`: (boolean) Indicates support for retrieving a more detailed Agent Card via an authenticated endpoint (optional).
65
+ - **`AgentCapabilities`:**
66
+ - `streaming`: (boolean) Supports `message/stream` and `tasks/resubscribe` for real-time updates via Server-Sent Events (SSE). Default: `false`.
67
+ - `pushNotifications`: (boolean) Supports `tasks/pushNotificationConfig/set|get` for asynchronous task updates via webhooks. Default: `false`.
68
+ - `stateTransitionHistory`: (boolean) Supports providing detailed history of status changes within the Task object (future enhancement). Default: `false`.
69
+ - **`AgentSkill`:**
70
+ - `id`: (string) Unique skill ID within this agent.
71
+ - `name`: (string) Human-readable skill name.
72
+ - `description`: (string) Detailed skill description. CommonMark may be used.
73
+ - `tags`: (string[]) Keywords/categories for discoverability.
74
+ - `examples`: (string[]) Example prompts or use cases demonstrating skill usage (optional).
75
+ - `inputModes`: (string[]) Overrides `defaultInputModes` for this specific skill. Accepted Media Types (optional).
76
+ - `outputModes`: (string[]) Overrides `defaultOutputModes` for this specific skill. Produced Media Types (optional).
77
+ - **`Task`:** Represents a unit of work processed by an agent.
78
+ - `id`: (string) Unique task identifier.
79
+ - `contextId`: (string) Groups related tasks in a conversation or session.
80
+ - `status`: (`TaskStatus`) Current state information.
81
+ - `artifacts`: (`Artifact[]`) Files/data produced by the agent (optional).
82
+ - `history`: (`TaskStatus[]`) Status transition history (optional, requires `stateTransitionHistory` capability).
83
+ - `metadata`: (object) Custom key-value data for client use (optional).
84
+ - `kind`: ("task") Type discriminator.
85
+ - **`TaskStatus`:**
86
+ - `state`: (`TaskState`) Current lifecycle state (enum).
87
+ - `message`: (string) Human-readable status message (optional).
88
+ - `timestamp`: (string) ISO-8601 timestamp of when this status was set.
89
+ - `kind`: ("status") Type discriminator.
90
+ - **`TaskState`:** (enum)
91
+ - `submitted`: Task received but not yet processing (non-terminal).
92
+ - `working`: Task is actively being processed (non-terminal).
93
+ - `input_required`: Task requires additional input from the client to proceed (non-terminal).
94
+ - `completed`: Task completed successfully (terminal).
95
+ - `failed`: Task encountered an error (terminal).
96
+ - `canceled`: Task was canceled by client request (terminal).
97
+ - `rejected`: Task was rejected by the agent (terminal).
98
+ - `auth-required`: Authentication required from client/user to proceed (non-terminal).
99
+ - `unknown`: Task state cannot be determined (terminal).
100
+ - **`Message`:** Communication unit between user and agent.
101
+ - `role`: ("user" | "agent") Sender role.
102
+ - `parts`: (`Part[]`) Content parts (text, file, data).
103
+ - `metadata`: (object | null) Message-specific metadata.
104
+ - `messageId`: (string) Unique identifier for the message.
105
+ - `parentMessageId`: (string) Reference to a previous message being replied to (optional).
106
+ - `rootMessageId`: (string) Reference to the first message in a thread (optional).
107
+ - `referenceTaskIds`: (string[]) List of tasks referenced as contextual hint by this message (optional).
108
+ - `taskId`: (string) Task identifier the current message is related to (optional).
109
+ - `contextId`: (string) Context identifier the message is associated with (optional).
110
+ - `kind`: ("message") Type discriminator.
111
+ - **`Part` (Union Type):** Represents a piece of content within a Message or Artifact.
112
+ - **`TextPart`:**
113
+ - `type`: "text"
114
+ - `text`: (string) Text content.
115
+ - `mimeType`: (string) Format specification (default: "text/plain").
116
+ - **`FilePart`:**
117
+ - `type`: "file"
118
+ - `file`: (`FileWithUri`) File reference with URI.
119
+ - `inline`: (boolean) Whether the file content should be displayed inline (optional).
120
+ - **`DataPart`:**
121
+ - `type`: "data"
122
+ - `data`: (any) Structured data in JSON-serializable format.
123
+ - `mimeType`: (string) Format specification (e.g., "application/json").
124
+ - `inline`: (boolean) Whether the data should be displayed inline (optional).
125
+ - `metadata`: (object | null) Optional metadata for the specific part.
126
+ - **`FileWithUri`:** Represents a file reference with URI.
127
+ - `name`: (string) Filename with extension.
128
+ - `mimeType`: (string) Content type (Media Type).
129
+ - `uri`: (string) URI to access the file content.
130
+ - **`Artifact`:** An output generated by a task.
131
+ - `artifactId`: (string) Unique identifier for the artifact.
132
+ - `name`: (string) Human-readable artifact name (optional).
133
+ - `description`: (string) Detailed description of the artifact (optional).
134
+ - `parts`: (`Part[]`) Content segments in the artifact.
135
+ - `metadata`: (object) Custom key-value data (optional).
136
+ - `kind`: ("artifact") Type discriminator.
137
+ - **`AuthenticationInfo`:** Authentication details for push notifications.
138
+ - `schemes`: (string[]) Array of authentication scheme names the caller must use.
139
+ - `credentials`: (string) Optional static credentials or scheme-specific configuration info.
140
+ - **`PushNotificationConfig`:** Configuration for push notifications.
141
+ - `url`: (string) Endpoint URL for the agent to POST notifications to.
142
+ - `token`: (string) Optional authentication token for the agent to include in requests (optional).
143
+ - `authentication`: (`AuthenticationInfo`) Authentication details the agent needs to call the URL (optional).
144
+ - **`TaskPushNotificationConfig`:** Associates a `PushNotificationConfig` with a task ID.
145
+ - `taskId`: (string) The task ID to receive push notifications for.
146
+ - `config`: (`PushNotificationConfig`) The push notification configuration to use.
147
+ - `metadata`: (object) Custom key-value data for client use (optional).
148
+ - **`MessageSendParams`:** Parameters for sending a message.
149
+ - `message`: (`Message`) The message to send.
150
+ - `configuration`: (`MessageSendConfiguration`) Optional configuration for the message.
151
+ - `metadata`: (object) Custom key-value data for client use (optional).
152
+ - **`agent/getAuthenticatedExtendedCard`:** (JSON-RPC Method)
153
+ - Retrieves a potentially more detailed version of the Agent Card after the client has authenticated.
154
+ - Available only if `AgentCard.supportsAuthenticatedExtendedCard` is `true`.
155
+ - Authentication: Required using one of the schemes declared in the public `AgentCard.securitySchemes`.
156
+ - Response: Complete `AgentCard` object with potentially additional details.
157
+
158
+ ### 2.3. A2A RPC Methods
159
+
160
+ - **`message/send`:** (Request/Response)
161
+ - Sends a message to initiate or continue a task.
162
+ - `params`: `MessageSendParams` (includes `taskId`, `contextId`, `message`, optionally `configuration`).
163
+ - `result`: `Task` (final state after synchronous processing).
164
+ - **`message/stream`:** (Request/Stream)
165
+ - Sends a message and subscribes to real-time updates via Server-Sent Events (SSE).
166
+ - `params`: `MessageSendParams`.
167
+ - `result` (stream events): `SendStreamingMessageResponse` containing one of: `MessageEvent`, `TaskStatusUpdateEvent`, `TaskArtifactUpdateEvent`. Final event has `final: true`.
168
+ - **`tasks/get`:** (Request/Response)
169
+ - Retrieves the current state of a task.
170
+ - `params`: `TaskQueryParams` (includes `id`, optionally `historyLength`).
171
+ - `result`: `Task`.
172
+ - **`tasks/cancel`:** (Request/Response)
173
+ - Requests cancellation of a running task.
174
+ - `params`: `TaskIdParams` (includes `id`).
175
+ - `result`: `Task` (updated state, likely 'canceled') or error if not cancelable.
176
+ - **`tasks/pushNotificationConfig/set`:** (Request/Response)
177
+ - Sets or updates the push notification configuration for a task.
178
+ - `params`: `TaskPushNotificationConfig`.
179
+ - `result`: `TaskPushNotificationConfig` (confirmed configuration).
180
+ - **`tasks/pushNotificationConfig/get`:** (Request/Response)
181
+ - Retrieves the current push notification configuration for a task.
182
+ - `params`: `TaskIdParams` (includes `taskId`).
183
+ - `result`: `TaskPushNotificationConfig`.
184
+ - **`tasks/resubscribe`:** (Request/Stream)
185
+ - Resubscribes to task updates after a connection interruption (SSE).
186
+ - `params`: `TaskQueryParams`.
187
+ - `result` (stream events): `TaskStatusUpdateEvent` or `TaskArtifactUpdateEvent`.
188
+
189
+ ### 2.4. Streaming Update Events (Result of `message/stream` or `tasks/resubscribe`)
190
+
191
+ - **`SendStreamingMessageResponse`:** Contains a message from the agent.
192
+ - `type`: "message"
193
+ - `message`: (`Message`) The message content.
194
+ - `contextId`: (string) Context identifier the message is associated with.
195
+ - `kind`: ("streaming-response") Type discriminator.
196
+ - `final`: (boolean) True if this is the final message for the task.
197
+ - **`TaskStatusUpdateEvent`:** Signals a change in task status.
198
+ - `type`: "task-status"
199
+ - `taskId`: (string) Task ID.
200
+ - `contextId`: (string) Context identifier the task is associated with.
201
+ - `kind`: ("status-update") Type discriminator.
202
+ - `status`: (`TaskStatus`) The new status object.
203
+ - `final`: (boolean) True if this is the terminal update for the task.
204
+ - **`TaskArtifactUpdateEvent`:** Signals a new or updated artifact.
205
+ - `type`: "task-artifact"
206
+ - `taskId`: (string) Task ID.
207
+ - `artifact`: (`Artifact`) The artifact data.
208
+ - `append`: (boolean) If true, append parts to artifact; if false (default), replace.
209
+ - `lastChunk`: (boolean) If true, indicates this is the final update for the artifact.
210
+ - `final`: (boolean) Usually false for artifacts, can signal end concurrently with status.
211
+
212
+ ### 2.5. Standard Error Codes
213
+
214
+ - `-32700`: `JSONParseError` - Invalid JSON payload.
215
+ - `-32600`: `InvalidRequestError` - Invalid JSON-RPC request object.
216
+ - `-32601`: `MethodNotFoundError` - Method does not exist.
217
+ - `-32602`: `InvalidParamsError` - Invalid method parameters.
218
+ - `-32603`: `InternalError` - Internal server error.
219
+
220
+ ### 2.6. A2A Specific Error Codes
221
+
222
+ - `-32001`: `TaskNotFoundError` - Specified task ID not found.
223
+ - `-32002`: `TaskNotCancelableError` - Task is in a terminal state and cannot be canceled.
224
+ - `-32003`: `PushNotificationNotSupportedError` - Agent does not support push notifications.
225
+ - `-32004`: `UnsupportedOperationError` - The requested operation is not supported.
226
+ - `-32005`: `ContentTypeNotSupportedError` - Mismatch in supported content types.
227
+ - `-32006`: `InvalidAgentResponseError` - Agent generated an invalid response for the requested method.
228
+
229
+ ## 3. Core Concepts
230
+
231
+ - **Agent Discovery:** Clients find agents and their capabilities by fetching the `AgentCard` JSON, typically from `/.well-known/agent-card.json`.
232
+ - **Task Lifecycle:** Tasks progress through states defined in `TaskState` (submitted -> working -> [input_required] -> completed/failed/canceled/rejected/unknown).
233
+ - **Communication:** Uses `Message` objects containing `Part`s (text, file, data). Task outputs are represented as `Artifact`s, also containing `Part`s.
234
+ - **Streaming:** Long-running tasks can provide real-time updates using Server-Sent Events (SSE) via `message/stream`. Updates are sent as `MessageEvent`, `TaskStatusUpdateEvent` and `TaskArtifactUpdateEvent`. Reconnection after interruptions is supported via `tasks/resubscribe`.
235
+ - **Push Notifications:** Agents can proactively notify clients about task updates using webhook URLs provided via `tasks/pushNotificationConfig/set`. Authentication mechanisms (e.g., Bearer tokens via JWT signed with keys from agent's JWKS endpoint) are supported for secure communication.
236
+ - **Authentication:** Defined in `AgentCard` (via `securitySchemes` and `security` fields) and `PushNotificationConfig`. Can involve various schemes (e.g., API keys, OAuth, JWT). The protocol supports authenticated extended Agent Card retrieval via the `agent/getAuthenticatedExtendedCard` JSON-RPC method. Samples use JWT for push notifications and secure communication.
237
+ - **Forms:** Structured data can be requested and submitted using `DataPart` within Messages/Artifacts (demonstrated in ADK sample).
238
+
239
+ ## 4. Security Considerations
240
+
241
+ - **Transport Security:** Always use HTTPS with strong TLS configurations in production environments.
242
+ - **Authentication:**
243
+ - Handled via standard HTTP mechanisms (e.g., `Authorization` header with Bearer tokens, API keys).
244
+ - Requirements are declared in the `AgentCard`.
245
+ - Credentials MUST be obtained out-of-band by the client.
246
+ - A2A Servers MUST authenticate every request.
247
+ - **Authorization:**
248
+ - A server-side responsibility based on the authenticated identity.
249
+ - Implement the principle of least privilege.
250
+ - Can be granular, based on skills, actions, or data.
251
+ - **Push Notification Security:**
252
+ - Webhook URL validation (by the A2A Server sending notifications) is crucial to prevent SSRF.
253
+ - Authentication of the A2A Server to the client's webhook is essential.
254
+ - Authentication of the notification by the client's webhook receiver (verifying it came from the legitimate A2A Server and is relevant) is critical.
255
+ - **Input Validation:** Servers MUST rigorously validate all RPC parameters and the content/structure of data in `Message` and `Artifact` parts to prevent injection attacks or processing errors.
256
+ - **Resource Management:** Implement rate limiting, concurrency controls, and resource limits to protect agents from abuse or overload.
257
+ - **Data Privacy:** Adhere to all applicable privacy regulations for data exchanged in `Message` and `Artifact` parts. Minimize sensitive data transfer.
258
+
259
+ ## 4. Implementations & Samples
260
+
261
+ ### 4.1. Common Libraries
262
+
263
+ - **Python (`samples/python/common`)**:
264
+ - `client/`: `A2AClient` for making requests, `A2ACardResolver` for discovery.
265
+ - `server/`: `A2AServer` (Starlette-based), `TaskManager` base class, `InMemoryTaskManager`.
266
+ - `types.py`: Pydantic models mirroring the JSON schema.
267
+ - `utils/`: Helpers for push notification auth (JWT signing/verification, JWKS endpoint).
268
+ - **JavaScript/TypeScript (`samples/js/src`)**:
269
+ - `client/`: `A2AClient` implementation using `fetch`.
270
+ - `server/`: `A2AServer` (Express-based), `TaskStore` interface, `InMemoryTaskStore`, `FileStore`.
271
+ - `schema.ts`: TypeScript interfaces matching the JSON schema.
272
+ - `handler.ts`, `error.ts`, `utils.ts`: Support code for the server.
273
+
274
+ ### 4.2. Python Samples
275
+
276
+ - **Location:** `samples/python/agents/` & `samples/python/hosts/`
277
+ - **Setup:** Uses `uv` and `pyproject.toml`. Requires Python >= 3.12/3.13. API keys via `.env`.
278
+ - **Agents:**
279
+ - **LangGraph (`agents/langgraph`)**: Currency conversion agent. Demonstrates tool use, multi-turn (`input-required`), and **streaming** (`tasks/sendSubscribe`).
280
+ - **CrewAI (`agents/crewai`)**: Image generation agent. Demonstrates multi-turn and handling **file artifacts** (images).
281
+ - **Google ADK (`agents/google_adk`)**: Expense reimbursement agent. Demonstrates multi-turn and handling **forms** using `DataPart`.
282
+ - **Hosts:**
283
+ - **CLI (`hosts/cli`)**: Simple command-line client to interact with any A2A agent. Supports streaming and optional push notification listening.
284
+ - **Multi-Agent Orchestrator (`hosts/multiagent`)**: An ADK-based "Host Agent" that manages connections (`RemoteAgentConnections`) to other A2A agents and delegates tasks based on instructions.
285
+
286
+ ### 4.3. JavaScript/TypeScript Samples
287
+
288
+ - **Location:** `samples/js/`
289
+ - **Setup:** Uses `npm`/`pnpm`, `tsx`, `tsconfig.json`. Requires Node.js >= 18. API keys via environment variables. Framework: **Genkit**.
290
+ - **Agents (`src/agents/`)**:
291
+ - **Movie Agent (`movie-agent`)**: Uses TMDB API via Genkit tools to answer movie questions. Demonstrates tool use and multi-turn (`AWAITING_USER_INPUT` mapped to `input-required`).
292
+ - **Coder Agent (`coder`)**: Generates code files. Demonstrates producing multiple **file artifacts** via streaming updates. Uses custom Genkit format (`code-format.ts`).
293
+ - **Hosts:**
294
+ - **CLI (`src/cli.ts`)**: Command-line client for interacting with JS agents.
295
+
296
+ ### 4.4. Demo Application (`demo/`)
297
+
298
+ - **UI (`demo/ui`)**: Web application built with **Mesop**.
299
+ - Visualizes conversations with multiple agents via the host orchestrator.
300
+ - Renders text, images, forms.
301
+ - Allows dynamic agent registration via URL.
302
+ - Provides views for task list and event logs.
303
+ - **Service (`demo/ui/service`)**: Backend service for the Mesop UI.
304
+ - `server/`: Manages conversations, routes messages, interfaces with the host agent (`ADKHostManager` or `InMemoryFakeAgentManager`).
305
+ - `client/`: Client used by the UI to talk to its *own* backend service.
306
+
307
+ ## 5. Development & Setup
308
+
309
+ - **Prerequisites:** Python (>=3.12 or 3.13), Node.js (>=18), `uv` (for Python), `npm`/`pnpm` (for JS).
310
+ - **API Keys:** Required for LLM access (e.g., `GOOGLE_API_KEY`, `TMDB_API_KEY`), typically set via `.env` files or environment variables.
311
+ - **Running Samples:** Generally involves running an agent server (`uv run ...` or `npm run ...`) and then a host client/app (e.g., `uv run hosts/cli --agent <agent_url>`).
312
+
313
+ ## 6. Contribution
314
+
315
+ - See `CONTRIBUTING.md`.
316
+ - GitHub discussion available as the primary means of communication.
317
+ - GitHub issues for bugs and feature requests.
318
+ - Google Form for private feedback.