a2a 0.1.0.pre → 0.1.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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +25 -4
  3. data/.tool-versions +1 -1
  4. data/CHANGELOG.md +19 -2
  5. data/Guardfile +1 -1
  6. data/README.md +49 -4
  7. data/lib/a2a/extensions/additional_properties.rb +121 -0
  8. data/lib/a2a/extensions/case_transformation.rb +46 -0
  9. data/lib/a2a/extensions/json_deserialization.rb +53 -0
  10. data/lib/a2a/types/agent_authentication.rb +13 -0
  11. data/lib/a2a/types/agent_capabilities.rb +15 -0
  12. data/lib/a2a/types/agent_card.rb +39 -0
  13. data/lib/a2a/types/agent_provider.rb +12 -0
  14. data/lib/a2a/types/agent_skill.rb +27 -0
  15. data/lib/a2a/types/artifact.rb +29 -0
  16. data/lib/a2a/types/authentication_info.rb +9 -0
  17. data/lib/a2a/types/cancel_task_request.rb +15 -0
  18. data/lib/a2a/types/cancel_task_response.rb +12 -0
  19. data/lib/a2a/types/data_part.rb +15 -0
  20. data/lib/a2a/types/error_codes.rb +26 -0
  21. data/lib/a2a/types/file_content.rb +18 -0
  22. data/lib/a2a/types/file_part.rb +15 -0
  23. data/lib/a2a/types/get_task_push_notification_request.rb +15 -0
  24. data/lib/a2a/types/get_task_push_notification_response.rb +12 -0
  25. data/lib/a2a/types/get_task_request.rb +15 -0
  26. data/lib/a2a/types/get_task_response.rb +12 -0
  27. data/lib/a2a/types/internal_error.rb +15 -0
  28. data/lib/a2a/types/invalid_params_error.rb +15 -0
  29. data/lib/a2a/types/invalid_request_error.rb +15 -0
  30. data/lib/a2a/types/json_parse_error.rb +15 -0
  31. data/lib/a2a/types/jsonrpc_error.rb +15 -0
  32. data/lib/a2a/types/jsonrpc_message.rb +12 -0
  33. data/lib/a2a/types/jsonrpc_request.rb +15 -0
  34. data/lib/a2a/types/jsonrpc_response.rb +12 -0
  35. data/lib/a2a/types/message.rb +15 -0
  36. data/lib/a2a/types/method_not_found_error.rb +15 -0
  37. data/lib/a2a/types/part.rb +6 -0
  38. data/lib/a2a/types/protocol_struct.rb +12 -0
  39. data/lib/a2a/types/push_notification_config.rb +15 -0
  40. data/lib/a2a/types/push_notification_not_supported_error.rb +15 -0
  41. data/lib/a2a/types/send_task_request.rb +15 -0
  42. data/lib/a2a/types/send_task_response.rb +13 -0
  43. data/lib/a2a/types/send_task_streaming_request.rb +15 -0
  44. data/lib/a2a/types/send_task_streaming_response.rb +15 -0
  45. data/lib/a2a/types/set_task_push_notification_request.rb +15 -0
  46. data/lib/a2a/types/set_task_push_notification_response.rb +12 -0
  47. data/lib/a2a/types/task.rb +25 -0
  48. data/lib/a2a/types/task_artifact_update_event.rb +18 -0
  49. data/lib/a2a/types/task_id_params.rb +12 -0
  50. data/lib/a2a/types/task_not_cancelable_error.rb +15 -0
  51. data/lib/a2a/types/task_not_found_error.rb +15 -0
  52. data/lib/a2a/types/task_push_notification_config.rb +12 -0
  53. data/lib/a2a/types/task_query_params.rb +9 -0
  54. data/lib/a2a/types/task_resubscription_request.rb +15 -0
  55. data/lib/a2a/types/task_send_params.rb +26 -0
  56. data/lib/a2a/types/task_state.rb +6 -0
  57. data/lib/a2a/types/task_status.rb +15 -0
  58. data/lib/a2a/types/task_status_update_event.rb +18 -0
  59. data/lib/a2a/types/text_part.rb +15 -0
  60. data/lib/a2a/types/unsupported_operation_error.rb +15 -0
  61. data/lib/a2a/types.rb +12 -0
  62. data/lib/a2a/version.rb +1 -1
  63. data/lib/a2a.rb +20 -1
  64. metadata +66 -319
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Request to retrieve the currently configured push notification configuration for a task.
5
+ class GetTaskPushNotificationRequest < JSONRPCRequest
6
+ # @return [String] Method name for getting task notification configuration.
7
+ attribute :method, Types::String.constant('tasks/pushNotification/get')
8
+
9
+ # @return [TaskIdParams] Parameters for the get task push notification config method.
10
+ attribute :params, Types::Constructor(TaskIdParams)
11
+
12
+ # @return [String] Method name for getting task notification configuration.
13
+ def method = attributes[:method]
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Response to a `tasks/pushNotification/get` request. Contains the TaskPushNotificationConfig or an error.
5
+ class GetTaskPushNotificationResponse < JSONRPCResponse
6
+ # @return [TaskPushNotificationConfig, nil] The push notification config if successful.
7
+ attribute? :result, Types::Constructor(TaskPushNotificationConfig).optional
8
+
9
+ # @return [JSONRPCError, nil] Error information if the request failed.
10
+ attribute? :error, Types::Constructor(JSONRPCError).optional
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Request to retrieve the current state of a task.
5
+ class GetTaskRequest < JSONRPCRequest
6
+ # @return [String] Method name for getting task status.
7
+ attribute :method, Types::String.constant('tasks/get')
8
+
9
+ # @return [TaskQueryParams] Parameters for the get task method.
10
+ attribute :params, Types::Constructor(TaskQueryParams)
11
+
12
+ # @return [String] Method name for getting task status.
13
+ def method = attributes[:method]
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Response to a `tasks/get` request. Contains the Task object or an error.
5
+ class GetTaskResponse < JSONRPCResponse
6
+ # @return [Task, nil] The task information if successful.
7
+ attribute? :result, Types::Constructor(Task).optional
8
+
9
+ # @return [JSONRPCError, nil] Error information if the request failed.
10
+ attribute? :error, Types::Constructor(JSONRPCError).optional
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Error for internal server errors
5
+ class InternalError < JSONRPCError
6
+ # @return [Integer] Error code (-32603)
7
+ attribute :code, Types::Integer.constant(ErrorCodes::INTERNAL_ERROR)
8
+
9
+ # @return [String] Error message
10
+ attribute :message, Types::String.constant('Internal error')
11
+
12
+ # @return [Object, nil] Additional error data
13
+ attribute? :data, Types::Nominal::Any.optional
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Error for invalid parameters
5
+ class InvalidParamsError < JSONRPCError
6
+ # @return [Integer] Error code (-32602)
7
+ attribute :code, Types::Integer.constant(ErrorCodes::INVALID_PARAMS)
8
+
9
+ # @return [String] Error message
10
+ attribute :message, Types::String.constant('Invalid parameters')
11
+
12
+ # @return [Object, nil] Additional error data
13
+ attribute? :data, Types::Nominal::Any.optional
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Error for invalid request structure
5
+ class InvalidRequestError < JSONRPCError
6
+ # @return [Integer] Error code (-32600)
7
+ attribute :code, Types::Integer.constant(ErrorCodes::INVALID_REQUEST)
8
+
9
+ # @return [String] Error message
10
+ attribute :message, Types::String.constant('Request payload validation error')
11
+
12
+ # @return [Object, nil] Additional error data
13
+ attribute? :data, Types::Nominal::Any.optional
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Error for invalid JSON payload
5
+ class JSONParseError < JSONRPCError
6
+ # @return [Integer] Error code (-32700)
7
+ attribute :code, Types::Integer.constant(ErrorCodes::PARSE_ERROR)
8
+
9
+ # @return [String] Error message
10
+ attribute :message, Types::String.constant('Invalid JSON payload')
11
+
12
+ # @return [Object, nil] Additional error data
13
+ attribute? :data, Types::Nominal::Any.optional
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents a JSON-RPC error object.
5
+ class JSONRPCError < ProtocolStruct
6
+ # @return [Integer] A number indicating the error type that occurred.
7
+ attribute :code, Types::Integer.constant(ErrorCodes::PARSE_ERROR)
8
+
9
+ # @return [String] A string providing a short description of the error.
10
+ attribute :message, Types::String.constant('Invalid JSON payload')
11
+
12
+ # @return [Object, nil] Optional additional data about the error.
13
+ attribute? :data, Types::Nominal::Any.optional
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents a base message for JSON-RPC communication.
5
+ class JSONRPCMessage < ProtocolStruct
6
+ # @return [String] Specifies the JSON-RPC version. Must be "2.0".
7
+ attribute? :jsonrpc, Types::String.constant('2.0')
8
+
9
+ # @return [Integer, String, nil] Request identifier. Responses must have the same ID as the request they relate to.
10
+ attribute? :id, (Types::Integer | Types::String).optional
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents a JSON-RPC request object.
5
+ class JSONRPCRequest < JSONRPCMessage
6
+ # @return [String] The name of the method to be invoked.
7
+ attribute :method, Types::String
8
+
9
+ # @return [Hash, nil] Parameters for the method. Can be a structured object, an array, or null/omitted.
10
+ attribute? :params, Types::Hash.optional
11
+
12
+ # @return [String] The name of the method to be invoked.
13
+ def method = attributes[:method]
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents a JSON-RPC response object.
5
+ class JSONRPCResponse < JSONRPCMessage
6
+ # @return [Object, nil] The result of the method invocation. Required on success.
7
+ attribute? :result, Types::Nominal::Any.optional
8
+
9
+ # @return [JSONRPCError, nil] An error object if an error occurred during the request. Required on failure.
10
+ attribute? :error, Types::Constructor(JSONRPCError).optional
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents a message exchanged between a user and an agent.
5
+ class Message < ProtocolStruct
6
+ # @return [String] The role of the sender (user or agent).
7
+ attribute :role, Types::String.enum('user', 'agent')
8
+
9
+ # @return [Array<Part>] The content of the message, composed of one or more parts.
10
+ attribute :parts, Types::Array.of(Types::Constructor(Part))
11
+
12
+ # @return [Hash, nil] Optional metadata associated with the message.
13
+ attribute? :metadata, Types::Hash.optional
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Error for method not found
5
+ class MethodNotFoundError < JSONRPCError
6
+ # @return [Integer] Error code (-32601)
7
+ attribute :code, Types::Integer.constant(ErrorCodes::METHOD_NOT_FOUND)
8
+
9
+ # @return [String] Error message
10
+ attribute :message, Types::String.constant('Method not found')
11
+
12
+ # @return [nil] No additional data
13
+ attribute? :data, Types::Nil.constant(nil)
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents a single part of a multi-part message. Can be text, file, or data.
5
+ Part = TextPart | FilePart | DataPart
6
+ end
@@ -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,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Information required for setting up push notifications.
5
+ class PushNotificationConfig < ProtocolStruct
6
+ # @return [String] The URL endpoint where the agent should send notifications.
7
+ attribute :url, Types::String
8
+
9
+ # @return [String, nil] A token to be included in push notification requests for verification/authentication.
10
+ attribute? :token, Types::String.optional
11
+
12
+ # @return [AuthenticationInfo, nil] Optional authentication details needed by the agent to call the notification URL
13
+ attribute? :authentication, Types::Constructor(AuthenticationInfo).optional
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Error for push notification not supported
5
+ class PushNotificationNotSupportedError < JSONRPCError
6
+ # @return [Integer] Error code (-32003)
7
+ attribute :code, Types::Integer.constant(ErrorCodes::PUSH_NOTIFICATION_NOT_SUPPORTED)
8
+
9
+ # @return [String] Error message
10
+ attribute :message, Types::String.constant('Push Notification is not supported')
11
+
12
+ # @return [nil] No additional data
13
+ attribute? :data, Types::Nil.constant(nil)
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Request to send a message/initiate a task.
5
+ class SendTaskRequest < JSONRPCRequest
6
+ # @return [String] Method name for sending a task message.
7
+ attribute :method, Types::String.constant('tasks/send')
8
+
9
+ # @return [TaskSendParams] Parameters for the send task method.
10
+ attribute :params, Types::Constructor(TaskSendParams)
11
+
12
+ # @return [String] The name of the method to be invoked.
13
+ def method = attributes[:method]
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Response to a `tasks/send` request.
5
+ # Contains the Task object or an error.
6
+ class SendTaskResponse < JSONRPCResponse
7
+ # @return [Task, nil] The resulting task if successful.
8
+ attribute? :result, Types::Constructor(Task).optional
9
+
10
+ # @return [JSONRPCError, nil] Error information if the request failed.
11
+ attribute? :error, Types::Constructor(JSONRPCError).optional
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Request to send a message/initiate a task and subscribe to streaming updates.
5
+ class SendTaskStreamingRequest < JSONRPCRequest
6
+ # @return [String] Method name for sending a task message and subscribing to updates.
7
+ attribute :method, Types::String.constant('tasks/sendSubscribe')
8
+
9
+ # @return [TaskSendParams] Parameters for the streaming task send method.
10
+ attribute :params, Types::Constructor(TaskSendParams)
11
+
12
+ # @return [String] Method name for sending a task message and subscribing to updates.
13
+ def method = attributes[:method]
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Response to a streaming task operation, either through `tasks/sendSubscribe` or a subscription.
5
+ # Contains a TaskStatusUpdateEvent, TaskArtifactUpdateEvent, or an error.
6
+ class SendTaskStreamingResponse < JSONRPCResponse
7
+ # @return [TaskStatusUpdateEvent, TaskArtifactUpdateEvent, nil] Event data if successful.
8
+ attribute? :result do
9
+ Types.Constructor(TaskStatusUpdateEvent) | Types.Constructor(TaskArtifactUpdateEvent)
10
+ end.optional
11
+
12
+ # @return [JSONRPCError, nil] Error information if the request failed.
13
+ attribute? :error, Types::Constructor(JSONRPCError).optional
14
+ end
15
+ end
@@ -0,0 +1,15 @@
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 < JSONRPCRequest
6
+ # @return [String] Method name for setting a task notifications.
7
+ attribute :method, Types::String.constant('tasks/pushNotification/set')
8
+
9
+ # @return [TaskPushNotificationConfig] Parameters for the set task push notification method.
10
+ attribute :params, Types::Constructor(TaskPushNotificationConfig)
11
+
12
+ # @return [String] Method name for setting a task notifications.
13
+ def method = attributes[:method]
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Response to a `tasks/pushNotification/set` request. Contains the TaskPushNotificationConfig or an error.
5
+ class SetTaskPushNotificationResponse < JSONRPCResponse
6
+ # @return [TaskPushNotificationConfig, nil] The push notification config if successful.
7
+ attribute? :result, Types::Constructor(TaskPushNotificationConfig).optional
8
+
9
+ # @return [JSONRPCError, nil] Error information if the request failed.
10
+ attribute? :error, Types::Constructor(JSONRPCError).optional
11
+ end
12
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents a task being processed by an agent.
5
+ class Task < ProtocolStruct
6
+ # @return [String] Unique identifier for the task.
7
+ attribute :id, Types::String
8
+
9
+ # @return [String, nil] Optional identifier for the session this task belongs to.
10
+ attribute? :session_id, Types::String.optional
11
+
12
+ # @return [TaskStatus] The current status of the task.
13
+ attribute :status, Types::Constructor(TaskStatus)
14
+
15
+ # @return [Array<Artifact>, nil] Optional list of artifacts associated with the task
16
+ # (e.g., outputs, intermediate files).
17
+ attribute? :artifacts, Types::Array.of(Types::Constructor(Artifact)).optional
18
+
19
+ # @return [Array<Message>, nil] Optional history of messages exchanged during the task.
20
+ attribute? :history, Types::Array.of(Types::Constructor(Message)).optional
21
+
22
+ # @return [Hash, nil] Optional metadata associated with the task.
23
+ attribute? :metadata, Types::Hash.optional
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents an artifact update event for a task, typically used in streaming scenarios.
5
+ class TaskArtifactUpdateEvent < ProtocolStruct
6
+ # @return [String] The ID of the task being updated.
7
+ attribute :id, Types::String
8
+
9
+ # @return [Artifact] The new or updated artifact for the task.
10
+ attribute :artifact, Types::Constructor(Artifact)
11
+
12
+ # @return [Boolean, nil] Flag indicating if this is the final update for the task.
13
+ attribute? :final, Types::Bool.optional
14
+
15
+ # @return [Hash, nil] Optional metadata associated with this update event.
16
+ attribute? :metadata, Types::Hash.optional
17
+ end
18
+ 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,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Error for task not cancelable
5
+ class TaskNotCancelableError < JSONRPCError
6
+ # @return [Integer] Error code (-32002)
7
+ attribute :code, Types::Integer.constant(ErrorCodes::TASK_NOT_CANCELABLE)
8
+
9
+ # @return [String] Error message
10
+ attribute :message, Types::String.constant('Task cannot be canceled')
11
+
12
+ # @return [nil] No additional data
13
+ attribute? :data, Types::Nil.constant(nil)
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Error for task not found
5
+ class TaskNotFoundError < JSONRPCError
6
+ # @return [Integer] Error code (-32001)
7
+ attribute :code, Types::Integer.constant(ErrorCodes::TASK_NOT_FOUND)
8
+
9
+ # @return [String] Error message
10
+ attribute :message, Types::String.constant('Task not found')
11
+
12
+ # @return [nil] No additional data
13
+ attribute? :data, Types::Nil.constant(nil)
14
+ end
15
+ 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,15 @@
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 < JSONRPCRequest
6
+ # @return [String] Method name for resubscribing to task updates.
7
+ attribute :method, Types::String.constant('tasks/resubscribe')
8
+
9
+ # @return [TaskQueryParams] Parameters for the task resubscription method.
10
+ attribute :params, Types::Constructor(TaskQueryParams)
11
+
12
+ # @return [String] Method name for resubscribing to task updates.
13
+ def method = attributes[:method]
14
+ end
15
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Parameters for the `tasks/send` method.
5
+ class TaskSendParams < ProtocolStruct
6
+ # @return [String] Unique identifier for the task being initiated or continued.
7
+ attribute :id, Types::String
8
+
9
+ # @return [String, nil] Optional identifier for the session this task belongs to. If not provided, a new
10
+ # session might be implicitly created depending on the agent.
11
+ attribute? :session_id, Types::String.optional
12
+
13
+ # @return [Message] The message content to send to the agent for processing.
14
+ attribute :message, Types::Constructor(Message)
15
+
16
+ # @return [PushNotificationConfig, nil] Optional pushNotification information for receiving notifications about
17
+ # this task. Requires agent capability.
18
+ attribute? :push_notification, Types::Constructor(PushNotificationConfig).optional
19
+
20
+ # @return [Integer, nil] Optional parameter to specify how much message history to include in the response.
21
+ attribute? :history_length, Types::Integer.optional
22
+
23
+ # @return [Hash, nil] Optional metadata associated with sending this message.
24
+ attribute? :metadata, Types::Hash.optional
25
+ end
26
+ end
@@ -0,0 +1,6 @@
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', 'unknown')
6
+ 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,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents a status update event for a task, typically used in streaming scenarios.
5
+ class TaskStatusUpdateEvent < ProtocolStruct
6
+ # @return [String] The ID of the task being updated.
7
+ attribute :id, Types::String
8
+
9
+ # @return [TaskStatus] The new status of the task.
10
+ attribute :status, Types::Constructor(TaskStatus)
11
+
12
+ # @return [Boolean] Flag indicating if this is the final update for the task.
13
+ attribute? :final, Types::Bool.default(false)
14
+
15
+ # @return [Hash, nil] Optional metadata associated with this update event.
16
+ attribute? :metadata, Types::Hash.optional
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Represents a part of a message containing text content.
5
+ class TextPart < ProtocolStruct
6
+ # @return [String] Type identifier for this part.
7
+ attribute :type, Types::String.constant('text')
8
+
9
+ # @return [String] The text content.
10
+ attribute :text, Types::String
11
+
12
+ # @return [Hash, nil] Optional metadata associated with this text part.
13
+ attribute? :metadata, Types::Hash.optional
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module A2A
4
+ # Error for unsupported operations
5
+ class UnsupportedOperationError < JSONRPCError
6
+ # @return [Integer] Error code (-32004)
7
+ attribute :code, Types::Integer.constant(ErrorCodes::UNSUPPORTED_OPERATION)
8
+
9
+ # @return [String] Error message
10
+ attribute :message, Types::String.constant('This operation is not supported')
11
+
12
+ # @return [nil] No additional data
13
+ attribute? :data, Types::Nil.constant(nil)
14
+ end
15
+ end
data/lib/a2a/types.rb ADDED
@@ -0,0 +1,12 @@
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
+ end
12
+ 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.1.0'
5
5
  end
data/lib/a2a.rb CHANGED
@@ -1,7 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'a2a/version'
3
+ require 'dry/inflector'
4
+ require 'zeitwerk'
4
5
 
5
6
  # Encapsulates all the gem's logic
6
7
  module A2A
8
+ # @!visibility private
9
+ # @return [Dry::Inflector] The inflector instance used for camelizing keys
10
+ INFLECTOR = Dry::Inflector.new
7
11
  end
12
+
13
+ loader = Zeitwerk::Loader.for_gem
14
+ loader.inflector.inflect(
15
+ 'a2a' => 'A2A',
16
+ 'json_deserialization' => 'JSONDeserialization',
17
+ 'jsonrpc_error' => 'JSONRPCError',
18
+ 'jsonrpc_message' => 'JSONRPCMessage',
19
+ 'jsonrpc_request' => 'JSONRPCRequest',
20
+ 'jsonrpc_response' => 'JSONRPCResponse',
21
+ 'json_parse_error' => 'JSONParseError'
22
+ )
23
+ loader.collapse("#{__dir__}/a2a/types")
24
+ loader.enable_reloading
25
+ loader.setup
26
+ loader.eager_load