a2a 0.1.0.pre → 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 (119) 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/.rubocop.yml +25 -4
  29. data/.tool-versions +1 -1
  30. data/CHANGELOG.md +86 -2
  31. data/CLAUDE.md +98 -0
  32. data/Guardfile +1 -1
  33. data/README.md +55 -4
  34. data/Rakefile +1 -3
  35. data/WARP.md +115 -0
  36. data/lib/a2a/extensions/additional_properties.rb +121 -0
  37. data/lib/a2a/extensions/case_transformation.rb +46 -0
  38. data/lib/a2a/extensions/json_deserialization.rb +51 -0
  39. data/lib/a2a/types/agent_capabilities.rb +18 -0
  40. data/lib/a2a/types/agent_card.rb +71 -0
  41. data/lib/a2a/types/agent_card_signature.rb +17 -0
  42. data/lib/a2a/types/agent_extension.rb +19 -0
  43. data/lib/a2a/types/agent_interface.rb +13 -0
  44. data/lib/a2a/types/agent_provider.rb +12 -0
  45. data/lib/a2a/types/agent_skill.rb +34 -0
  46. data/lib/a2a/types/api_key_security_scheme.rb +15 -0
  47. data/lib/a2a/types/artifact.rb +24 -0
  48. data/lib/a2a/types/authenticated_extended_card_not_configured_error.rb +43 -0
  49. data/lib/a2a/types/authorization_code_oauth_flow.rb +22 -0
  50. data/lib/a2a/types/cancel_task_request.rb +18 -0
  51. data/lib/a2a/types/cancel_task_response.rb +12 -0
  52. data/lib/a2a/types/client_credentials_oauth_flow.rb +16 -0
  53. data/lib/a2a/types/content_type_not_supported_error.rb +42 -0
  54. data/lib/a2a/types/data_part.rb +12 -0
  55. data/lib/a2a/types/delete_task_push_notification_config_params.rb +9 -0
  56. data/lib/a2a/types/delete_task_push_notification_config_request.rb +18 -0
  57. data/lib/a2a/types/delete_task_push_notification_config_response.rb +13 -0
  58. data/lib/a2a/types/error.rb +19 -0
  59. data/lib/a2a/types/error_codes.rb +32 -0
  60. data/lib/a2a/types/file_base.rb +12 -0
  61. data/lib/a2a/types/file_part.rb +13 -0
  62. data/lib/a2a/types/file_with_bytes.rb +9 -0
  63. data/lib/a2a/types/file_with_uri.rb +9 -0
  64. data/lib/a2a/types/get_authenticated_extended_card_request.rb +15 -0
  65. data/lib/a2a/types/get_authenticated_extended_card_response.rb +13 -0
  66. data/lib/a2a/types/get_task_push_notification_config_params.rb +9 -0
  67. data/lib/a2a/types/get_task_push_notification_config_request.rb +21 -0
  68. data/lib/a2a/types/get_task_push_notification_request.rb +18 -0
  69. data/lib/a2a/types/get_task_push_notification_response.rb +12 -0
  70. data/lib/a2a/types/get_task_request.rb +18 -0
  71. data/lib/a2a/types/get_task_response.rb +12 -0
  72. data/lib/a2a/types/http_auth_security_scheme.rb +18 -0
  73. data/lib/a2a/types/implicit_oauth_flow.rb +16 -0
  74. data/lib/a2a/types/invalid_agent_response_error.rb +41 -0
  75. data/lib/a2a/types/list_task_push_notification_config_params.rb +8 -0
  76. data/lib/a2a/types/list_task_push_notification_config_request.rb +18 -0
  77. data/lib/a2a/types/list_task_push_notification_config_response.rb +13 -0
  78. data/lib/a2a/types/message.rb +35 -0
  79. data/lib/a2a/types/message_send_configuration.rb +20 -0
  80. data/lib/a2a/types/message_send_params.rb +16 -0
  81. data/lib/a2a/types/mutual_tls_security_scheme.rb +9 -0
  82. data/lib/a2a/types/oauth2_security_scheme.rb +16 -0
  83. data/lib/a2a/types/oauth_flows.rb +20 -0
  84. data/lib/a2a/types/openid_connect_security_scheme.rb +12 -0
  85. data/lib/a2a/types/part.rb +7 -0
  86. data/lib/a2a/types/part_base.rb +9 -0
  87. data/lib/a2a/types/password_oauth_flow.rb +16 -0
  88. data/lib/a2a/types/protocol_struct.rb +12 -0
  89. data/lib/a2a/types/push_notification_authentication_info.rb +12 -0
  90. data/lib/a2a/types/push_notification_config.rb +20 -0
  91. data/lib/a2a/types/push_notification_not_supported_error.rb +42 -0
  92. data/lib/a2a/types/request.rb +15 -0
  93. data/lib/a2a/types/security_scheme.rb +11 -0
  94. data/lib/a2a/types/security_scheme_base.rb +9 -0
  95. data/lib/a2a/types/send_message_request.rb +18 -0
  96. data/lib/a2a/types/send_message_response.rb +13 -0
  97. data/lib/a2a/types/send_streaming_message_request.rb +18 -0
  98. data/lib/a2a/types/send_streaming_message_response.rb +15 -0
  99. data/lib/a2a/types/set_task_push_notification_config_request.rb +18 -0
  100. data/lib/a2a/types/set_task_push_notification_request.rb +18 -0
  101. data/lib/a2a/types/set_task_push_notification_response.rb +12 -0
  102. data/lib/a2a/types/task.rb +29 -0
  103. data/lib/a2a/types/task_artifact_update_event.rb +29 -0
  104. data/lib/a2a/types/task_id_params.rb +12 -0
  105. data/lib/a2a/types/task_not_cancelable_error.rb +42 -0
  106. data/lib/a2a/types/task_not_found_error.rb +42 -0
  107. data/lib/a2a/types/task_push_notification_config.rb +12 -0
  108. data/lib/a2a/types/task_query_params.rb +9 -0
  109. data/lib/a2a/types/task_resubscription_request.rb +18 -0
  110. data/lib/a2a/types/task_state.rb +7 -0
  111. data/lib/a2a/types/task_status.rb +15 -0
  112. data/lib/a2a/types/task_status_update_event.rb +25 -0
  113. data/lib/a2a/types/text_part.rb +12 -0
  114. data/lib/a2a/types/transport_protocol.rb +6 -0
  115. data/lib/a2a/types/unsupported_operation_error.rb +42 -0
  116. data/lib/a2a/types.rb +25 -0
  117. data/lib/a2a/version.rb +1 -1
  118. data/lib/a2a.rb +30 -1
  119. metadata +128 -299
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry-struct'
4
+
5
+ module A2A
6
+ # Base class for all A2A struct objects
7
+ # @!visibility private
8
+ class ProtocolStruct < Dry::Struct
9
+ include Extensions::CaseTransformation
10
+ include Extensions::JSONDeserialization
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Defines authentication details for a push notification endpoint.
5
+ class PushNotificationAuthenticationInfo < ProtocolStruct
6
+ # @return [Array<String>] A list of supported authentication schemes (e.g., 'Basic', 'Bearer').
7
+ attribute :schemes, Types::Array.of(Types::String)
8
+
9
+ # @return [String, nil] Optional credentials required by the push notification endpoint.
10
+ attribute? :credentials, Types::String.optional
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Defines the configuration for setting up push notifications for task updates.
5
+ class PushNotificationConfig < ProtocolStruct
6
+ # @return [String, nil] A unique identifier (e.g. UUID) for the push notification configuration, set by the client
7
+ # to support multiple notification callbacks.
8
+ attribute? :id, Types::String.optional
9
+
10
+ # @return [URI] The callback URL where the agent should send push notifications.
11
+ attribute :url, Types::URI
12
+
13
+ # @return [String, nil] A unique token for this task or session to validate incoming push notifications.
14
+ attribute? :token, Types::String.optional
15
+
16
+ # @return [PushNotificationAuthenticationInfo, nil] Optional authentication details for the agent to use when
17
+ # calling the notification URL.
18
+ attribute? :authentication, Types::Constructor(PushNotificationAuthenticationInfo).optional
19
+ end
20
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Error for unsupported push notifications (-32003)
5
+ #
6
+ # Raised when client attempts to use push notification features but the server agent
7
+ # does not support them (i.e., AgentCard.capabilities.pushNotifications is false).
8
+ #
9
+ # @api public
10
+ #
11
+ # @example Create a push notification not supported error
12
+ # error = JSONRPC::PushNotificationNotSupportedError.new
13
+ #
14
+ class PushNotificationNotSupportedError < JSONRPC::Error
15
+ # Creates a new Push Notification Not Supported Error with code -32003
16
+ #
17
+ # @api public
18
+ #
19
+ # @example Create a push notification not supported error with default message
20
+ # error = JSONRPC::PushNotificationNotSupportedError.new
21
+ #
22
+ # @example Create a push notification not supported error with exception details
23
+ # error = JSONRPC::PushNotificationNotSupportedError.new(data: { capability: false }, request_id: 1)
24
+ #
25
+ # @param message [String] short description of the error
26
+ # @param data [Hash, Array, String, Number, Boolean, nil] additional error information
27
+ # @param request_id [String, Integer, nil] the request identifier
28
+ #
29
+ def initialize(
30
+ message = 'Push Notification is not supported.',
31
+ data: nil,
32
+ request_id: nil
33
+ )
34
+ super(
35
+ message,
36
+ code: ErrorCodes::PUSH_NOTIFICATION_NOT_SUPPORTED,
37
+ data:,
38
+ request_id:
39
+ )
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # A discriminated union representing all possible JSON-RPC 2.0 requests supported by the A2A specification.
5
+ Request = SendMessageRequest |
6
+ SendStreamingMessageRequest |
7
+ GetTaskRequest |
8
+ CancelTaskRequest |
9
+ SetTaskPushNotificationConfigRequest |
10
+ GetTaskPushNotificationConfigRequest |
11
+ TaskResubscriptionRequest |
12
+ ListTaskPushNotificationConfigRequest |
13
+ DeleteTaskPushNotificationConfigRequest |
14
+ GetAuthenticatedExtendedCardRequest
15
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # A discriminated union representing a security scheme that can be used to secure an agent's endpoints.
5
+ # This is a discriminated union type based on the OpenAPI 3.0 Security Scheme Object.
6
+ SecurityScheme = APIKeySecurityScheme |
7
+ HTTPAuthSecurityScheme |
8
+ OAuth2SecurityScheme |
9
+ OpenIdConnectSecurityScheme |
10
+ MutualTLSSecurityScheme
11
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Defines base properties shared by all security scheme objects.
5
+ class SecuritySchemeBase < ProtocolStruct
6
+ # @return [String, nil] An optional description for the security scheme.
7
+ attribute? :description, Types::String.optional
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents a JSON-RPC request for the `message/send` method.
5
+ class SendMessageRequest < JSONRPC::Request
6
+ # @return [String] Method name for sending a message.
7
+ METHOD = 'message/send'
8
+
9
+ # @return [String] Method name for sending a message.
10
+ attribute :method, Types::String.constant(METHOD)
11
+
12
+ # @return [MessageSendParams] Parameters for sending a message.
13
+ attribute :params, Types::Constructor(MessageSendParams)
14
+
15
+ # @return [String] Method name for sending a message.
16
+ def method = attributes[:method]
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Response to a `message/send` request.
5
+ # Returns either a direct Message reply or the initial Task object.
6
+ class SendMessageResponse < JSONRPC::Response
7
+ # @return [Message, Task, nil] The result, which can be a direct reply Message or the initial Task object.
8
+ attribute? :result, Types::Any.optional
9
+
10
+ # @return [JSONRPC::Error, nil] Error information if the request failed.
11
+ attribute? :error, Types::Constructor(JSONRPC::Error).optional
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents a JSON-RPC request for the `message/stream` method.
5
+ class SendStreamingMessageRequest < JSONRPC::Request
6
+ # @return [String] Method name for streaming a message.
7
+ METHOD = 'message/stream'
8
+
9
+ # @return [String] Method name for streaming a message.
10
+ attribute :method, Types::String.constant(METHOD)
11
+
12
+ # @return [MessageSendParams] Parameters for streaming a message.
13
+ attribute :params, Types::Constructor(MessageSendParams)
14
+
15
+ # @return [String] Method name for streaming a message.
16
+ def method = attributes[:method]
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Response to a `message/stream` request.
5
+ # The server may send multiple response objects for a single request.
6
+ # Returns a Message, Task, or streaming update events.
7
+ class SendStreamingMessageResponse < JSONRPC::Response
8
+ # @return [Message, Task, TaskStatusUpdateEvent, TaskArtifactUpdateEvent, nil]
9
+ # The result, which can be a Message, Task, or streaming update event.
10
+ attribute? :result, Types::Any.optional
11
+
12
+ # @return [JSONRPC::Error, nil] Error information if the request failed.
13
+ attribute? :error, Types::Constructor(JSONRPC::Error).optional
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents a JSON-RPC request for the `tasks/pushNotificationConfig/set` method.
5
+ class SetTaskPushNotificationConfigRequest < JSONRPC::Request
6
+ # @return [String] Method name for setting task push notification configuration.
7
+ METHOD = 'tasks/pushNotificationConfig/set'
8
+
9
+ # @return [String] Method name for setting task push notification configuration.
10
+ attribute :method, Types::String.constant(METHOD)
11
+
12
+ # @return [TaskPushNotificationConfig] Parameters for setting the push notification configuration.
13
+ attribute :params, Types::Constructor(TaskPushNotificationConfig)
14
+
15
+ # @return [String] Method name for setting task push notification configuration.
16
+ def method = attributes[:method]
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Request to set or update the push notification config for a task.
5
+ class SetTaskPushNotificationRequest < JSONRPC::Request
6
+ # @return [String] Method name for setting a task notifications.
7
+ METHOD = 'tasks/pushNotificationConfig/set'
8
+
9
+ # @return [String] Method name for setting a task notifications.
10
+ attribute :method, Types::String.constant(METHOD)
11
+
12
+ # @return [TaskPushNotificationConfig] Parameters for the set task push notification method.
13
+ attribute :params, Types::Constructor(TaskPushNotificationConfig)
14
+
15
+ # @return [String] Method name for setting a task notifications.
16
+ def method = attributes[:method]
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Response to a `tasks/pushNotificationConfig/set` request. Contains the TaskPushNotificationConfig or an error.
5
+ class SetTaskPushNotificationResponse < JSONRPC::Response
6
+ # @return [TaskPushNotificationConfig, nil] The push notification config if successful.
7
+ attribute? :result, Types::Constructor(TaskPushNotificationConfig).optional
8
+
9
+ # @return [JSONRPC::Error, nil] Error information if the request failed.
10
+ attribute? :error, Types::Constructor(JSONRPC::Error).optional
11
+ end
12
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents a single, stateful operation or conversation between a client and an agent.
5
+ class Task < ProtocolStruct
6
+ # @return [String] A unique identifier (e.g. UUID) for the task, generated by the server for a new task.
7
+ attribute :id, Types::String
8
+
9
+ # @return [String] A server-generated unique identifier (e.g. UUID) for maintaining context across multiple related
10
+ # tasks or interactions.
11
+ attribute :context_id, Types::String
12
+
13
+ # @return [TaskStatus] The current status of the task, including its state and a descriptive message.
14
+ attribute :status, Types::Constructor(TaskStatus)
15
+
16
+ # @return [Array<Message>, nil] An array of messages exchanged during the task, representing the conversation
17
+ # history.
18
+ attribute? :history, Types::Array.of(Types::Constructor(Message)).optional
19
+
20
+ # @return [Array<Artifact>, nil] A collection of artifacts generated by the agent during the execution of the task.
21
+ attribute? :artifacts, Types::Array.of(Types::Constructor(Artifact)).optional
22
+
23
+ # @return [Hash, nil] Optional metadata for extensions. The key is an extension-specific identifier.
24
+ attribute? :metadata, Types::Hash.optional
25
+
26
+ # @return [String] The type of this object, used as a discriminator. Always 'task' for a Task.
27
+ attribute :kind, Types::String.constant('task')
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # An event sent by the agent to notify the client that an artifact has been
5
+ # generated or updated. This is typically used in streaming models.
6
+ class TaskArtifactUpdateEvent < ProtocolStruct
7
+ # @return [String] The ID of the task this artifact belongs to.
8
+ attribute :task_id, Types::String
9
+
10
+ # @return [String] The context ID associated with the task.
11
+ attribute :context_id, Types::String
12
+
13
+ # @return [String] The type of this event, used as a discriminator. Always 'artifact-update'.
14
+ attribute :kind, Types::String.constant('artifact-update')
15
+
16
+ # @return [Artifact] The artifact that was generated or updated.
17
+ attribute :artifact, Types::Constructor(Artifact)
18
+
19
+ # @return [Boolean, nil] If true, the content of this artifact should be appended to a previously sent artifact
20
+ # with the same ID.
21
+ attribute? :append, Types::Bool.optional
22
+
23
+ # @return [Boolean, nil] If true, this is the final chunk of the artifact.
24
+ attribute? :last_chunk, Types::Bool.optional
25
+
26
+ # @return [Hash, nil] Optional metadata for extensions.
27
+ attribute? :metadata, Types::Hash.optional
28
+ end
29
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Basic parameters used for task ID operations.
5
+ class TaskIdParams < ProtocolStruct
6
+ # @return [String] The unique identifier of the task.
7
+ attribute :id, Types::String
8
+
9
+ # @return [Hash, nil] Optional metadata to include with the operation.
10
+ attribute? :metadata, Types::Hash.optional
11
+ end
12
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Error non-cancelable tasks (-32002)
5
+ #
6
+ # Raised when a task cannot be canceled. An attempt was made to cancel a task that is not in a cancelable state
7
+ # (e.g., it has already reached a terminal state like completed, failed, or canceled).
8
+ #
9
+ # @api public
10
+ #
11
+ # @example Create a task not cancelable error
12
+ # error = JSONRPC::Errors::TaskNotCancelableError.new
13
+ #
14
+ class TaskNotCancelableError < JSONRPC::Error
15
+ # Creates a new Task Not Cancelable Error with code -32002
16
+ #
17
+ # @api public
18
+ #
19
+ # @example Create a task not cancelable error with default message
20
+ # error = JSONRPC::TaskNotCancelableError.new
21
+ #
22
+ # @example Create a task not cancelable error with exception details
23
+ # error = JSONRPC::TaskNotCancelableError.new(data: { exception: 'Task reached terminal state' }, request_id: 1)
24
+ #
25
+ # @param message [String] short description of the error
26
+ # @param data [Hash, Array, String, Number, Boolean, nil] additional error information
27
+ # @param request_id [String, Integer, nil] the request identifier
28
+ #
29
+ def initialize(
30
+ message = 'Task cannot be canceled.',
31
+ data: nil,
32
+ request_id: nil
33
+ )
34
+ super(
35
+ message,
36
+ code: ErrorCodes::TASK_NOT_CANCELABLE,
37
+ data:,
38
+ request_id:
39
+ )
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Error for missing tasks (-32001)
5
+ #
6
+ # Raised when the specified task ID does not correspond to an existing or active task.
7
+ # It might be invalid, expired, or already completed and purged.
8
+ #
9
+ # @api public
10
+ #
11
+ # @example Create a task not found error
12
+ # error = JSONRPC::TaskNotFoundError.new
13
+ #
14
+ class TaskNotFoundError < JSONRPC::Error
15
+ # Creates a new Task Not Found Error with code -32001
16
+ #
17
+ # @api public
18
+ #
19
+ # @example Create a task not found error with default message
20
+ # error = JSONRPC::TaskNotFoundError.new
21
+ #
22
+ # @example Create a task not found error with exception details
23
+ # error = JSONRPC::TaskNotFoundError.new(data: { task_id: 'invalid-id' }, request_id: 1)
24
+ #
25
+ # @param message [String] short description of the error
26
+ # @param data [Hash, Array, String, Number, Boolean, nil] additional error information
27
+ # @param request_id [String, Integer, nil] the request identifier
28
+ #
29
+ def initialize(
30
+ message = 'Task not found.',
31
+ data: nil,
32
+ request_id: nil
33
+ )
34
+ super(
35
+ message,
36
+ code: ErrorCodes::TASK_NOT_FOUND,
37
+ data:,
38
+ request_id:
39
+ )
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents the push notification information associated with a specific task ID.
5
+ class TaskPushNotificationConfig < ProtocolStruct
6
+ # @return [String] The ID of the task the notification config is associated with.
7
+ attribute :id, Types::String
8
+
9
+ # @return [PushNotificationConfig] The push notification configuration details.
10
+ attribute :push_notification_config, Types::Constructor(PushNotificationConfig)
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Parameters used for querying task-related information by ID.
5
+ class TaskQueryParams < TaskIdParams
6
+ # @return [Integer, nil] Optional history length to retrieve for the task.
7
+ attribute? :history_length, Types::Integer.optional
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Request to resubscribe to updates for a task after a connection interruption.
5
+ class TaskResubscriptionRequest < JSONRPC::Request
6
+ # @return [String] Method name for resubscribing to task updates.
7
+ METHOD = 'tasks/resubscribe'
8
+
9
+ # @return [String] Method name for resubscribing to task updates.
10
+ attribute :method, Types::String.constant(METHOD)
11
+
12
+ # @return [TaskQueryParams] Parameters for the task resubscription method.
13
+ attribute :params, Types::Constructor(TaskQueryParams)
14
+
15
+ # @return [String] Method name for resubscribing to task updates.
16
+ def method = attributes[:method]
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # The current state of the task
5
+ TaskState = Types::String.enum('submitted', 'working', 'input-required', 'completed', 'canceled', 'failed',
6
+ 'rejected', 'auth-required', 'unknown')
7
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents the status of a task at a specific point in time.
5
+ class TaskStatus < ProtocolStruct
6
+ # @return [String] The current state of the task.
7
+ attribute :state, TaskState
8
+
9
+ # @return [Message, nil] An optional message associated with the current status.
10
+ attribute? :message, Types::Constructor(Message).optional
11
+
12
+ # @return [DateTime, nil] The timestamp when this status was recorded (ISO 8601 format).
13
+ attribute? :timestamp, Types::JSON::DateTime.optional
14
+ end
15
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # An event sent by the agent to notify the client of a change in a task's status.
5
+ # This is typically used in streaming or subscription models.
6
+ class TaskStatusUpdateEvent < ProtocolStruct
7
+ # @return [String] The ID of the task that was updated.
8
+ attribute :task_id, Types::String
9
+
10
+ # @return [String] The context ID associated with the task.
11
+ attribute :context_id, Types::String
12
+
13
+ # @return [String] The type of this event, used as a discriminator. Always 'status-update'.
14
+ attribute :kind, Types::String.constant('status-update')
15
+
16
+ # @return [TaskStatus] The new status of the task.
17
+ attribute :status, Types::Constructor(TaskStatus)
18
+
19
+ # @return [Boolean] If true, this is the final event in the stream for this interaction.
20
+ attribute :final, Types::Bool
21
+
22
+ # @return [Hash, nil] Optional metadata for extensions.
23
+ attribute? :metadata, Types::Hash.optional
24
+ end
25
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents a text segment within a message or artifact.
5
+ class TextPart < PartBase
6
+ # @return [String] The type of this part, used as a discriminator. Always 'text'.
7
+ attribute :kind, Types::String.constant('text')
8
+
9
+ # @return [String] The string content of the text part.
10
+ attribute :text, Types::String
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Supported A2A transport protocols.
5
+ TransportProtocol = Types::String.enum('JSONRPC', 'GRPC', 'HTTP+JSON')
6
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Error for unsupported operations (-32004)
5
+ #
6
+ # Raised when the requested operation or a specific aspect of it (perhaps implied by parameters)
7
+ # is not supported by this server agent implementation. Broader than just method not found.
8
+ #
9
+ # @api public
10
+ #
11
+ # @example Create an unsupported operation error
12
+ # error = JSONRPC::UnsupportedOperationError.new
13
+ #
14
+ class UnsupportedOperationError < JSONRPC::Error
15
+ # Creates a new Unsupported Operation Error with code -32004
16
+ #
17
+ # @api public
18
+ #
19
+ # @example Create an unsupported operation error with default message
20
+ # error = JSONRPC::UnsupportedOperationError.new
21
+ #
22
+ # @example Create an unsupported operation error with exception details
23
+ # error = JSONRPC::UnsupportedOperationError.new(data: { operation: 'streaming' }, request_id: 1)
24
+ #
25
+ # @param message [String] short description of the error
26
+ # @param data [Hash, Array, String, Number, Boolean, nil] additional error information
27
+ # @param request_id [String, Integer, nil] the request identifier
28
+ #
29
+ def initialize(
30
+ message = 'This operation is not supported.',
31
+ data: nil,
32
+ request_id: nil
33
+ )
34
+ super(
35
+ message,
36
+ code: ErrorCodes::UNSUPPORTED_OPERATION,
37
+ data:,
38
+ request_id:
39
+ )
40
+ end
41
+ end
42
+ end
data/lib/a2a/types.rb ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry-types'
4
+
5
+ module A2A
6
+ # @!visibility private
7
+ module Types
8
+ include Dry.Types()
9
+
10
+ Dry::Types.define_builder(:constant) { |type, value| type.default(value).enum(value) }
11
+
12
+ # Custom URI type that accepts both String and URI objects
13
+ # and ensures the result is always a URI object
14
+ URI = Types.Constructor(::URI) do |value|
15
+ case value
16
+ when ::URI
17
+ value
18
+ when String
19
+ ::URI.parse(value)
20
+ else
21
+ raise ArgumentError, "Expected String or URI, got #{value.class}"
22
+ end
23
+ end
24
+ end
25
+ end
data/lib/a2a/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module A2A
4
- VERSION = '0.1.0.pre'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/a2a.rb CHANGED
@@ -1,7 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'a2a/version'
3
+ require 'dry/inflector'
4
+ require 'zeitwerk'
5
+ require 'jsonrpc'
6
+ require 'a2a/rails/railtie' if defined?(Rails)
4
7
 
5
8
  # Encapsulates all the gem's logic
6
9
  module A2A
10
+ # @!visibility private
11
+ # @return [Dry::Inflector] The inflector instance used for camelizing keys
12
+ INFLECTOR = Dry::Inflector.new
7
13
  end
14
+
15
+ loader = Zeitwerk::Loader.for_gem
16
+ loader.inflector.inflect(
17
+ 'a2a' => 'A2A',
18
+ 'api_key_security_scheme' => 'APIKeySecurityScheme',
19
+ 'authorization_code_oauth_flow' => 'AuthorizationCodeOAuthFlow',
20
+ 'client_credentials_oauth_flow' => 'ClientCredentialsOAuthFlow',
21
+ 'http_auth_security_scheme' => 'HTTPAuthSecurityScheme',
22
+ 'implicit_oauth_flow' => 'ImplicitOAuthFlow',
23
+ 'json_deserialization' => 'JSONDeserialization',
24
+ 'jsonrpc_helpers' => 'JSONRPCHelpers',
25
+ 'mutual_tls_security_scheme' => 'MutualTLSSecurityScheme',
26
+ 'oauth2_security_scheme' => 'OAuth2SecurityScheme',
27
+ 'oauth_flows' => 'OAuthFlows',
28
+ 'openid_connect_security_scheme' => 'OpenIdConnectSecurityScheme',
29
+ 'password_oauth_flow' => 'PasswordOAuthFlow',
30
+ 'uri' => 'URI'
31
+ )
32
+ loader.collapse("#{__dir__}/a2a/types")
33
+ loader.ignore("#{__dir__}/a2a/rails/railtie.rb")
34
+ loader.enable_reloading
35
+ loader.setup
36
+ loader.eager_load