Class: A2A::AgentCard
- Inherits:
-
Object
- Object
- A2A::AgentCard
- Defined in:
- lib/a2a/agent_card.rb,
lib/a2a/agent_card/builder.rb,
lib/a2a/agent_card/verifier.rb,
lib/a2a/agent_card/signature.rb
Defined Under Namespace
Classes: Builder, Signature, Verifier
Instance Attribute Summary collapse
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#default_input_modes ⇒ Object
readonly
Returns the value of attribute default_input_modes.
-
#default_output_modes ⇒ Object
readonly
Returns the value of attribute default_output_modes.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#documentation_url ⇒ Object
readonly
Returns the value of attribute documentation_url.
-
#icon_url ⇒ Object
readonly
Returns the value of attribute icon_url.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#security_requirements ⇒ Object
readonly
Returns the value of attribute security_requirements.
-
#security_schemes ⇒ Object
readonly
Returns the value of attribute security_schemes.
-
#signatures ⇒ Object
readonly
Returns the value of attribute signatures.
-
#skills ⇒ Object
readonly
Returns the value of attribute skills.
-
#supported_interfaces ⇒ Object
readonly
Returns the value of attribute supported_interfaces.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
-
.from_h(hash) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
Instance Method Summary collapse
-
#canonical_json ⇒ Object
§8.4.1 — RFC 8785 canonical JSON: to_h with “signatures” excluded and keys sorted recursively.
-
#initialize(name:, description:, **kwargs) ⇒ AgentCard
constructor
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
-
#preferred_interface(preference: [AgentInterface::JSONRPC, AgentInterface::HTTP_JSON]) ⇒ Object
§5.2 — returns the first interface whose protocolBinding the caller supports, preserving the agent’s declared preference order (index 0 = most preferred).
-
#to_h ⇒ Object
rubocop:enable Metrics/AbcSize, Metrics/MethodLength.
Constructor Details
#initialize(name:, description:, **kwargs) ⇒ AgentCard
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/a2a/agent_card.rb', line 15 def initialize(name:, description:, **kwargs) supported_interfaces = kwargs.fetch(:supported_interfaces) default_input_modes = kwargs.fetch(:default_input_modes) default_output_modes = kwargs.fetch(:default_output_modes) skills = kwargs.fetch(:skills) validate_required_collections!(supported_interfaces, default_input_modes, default_output_modes, skills) @name = name @description = description @supported_interfaces = supported_interfaces @version = kwargs.fetch(:version) @capabilities = kwargs.fetch(:capabilities) @default_input_modes = default_input_modes @default_output_modes = default_output_modes @skills = skills @provider = kwargs.fetch(:provider, nil) @documentation_url = kwargs.fetch(:documentation_url, nil) @security_schemes = kwargs.fetch(:security_schemes, nil) @security_requirements = kwargs.fetch(:security_requirements, nil) @signatures = kwargs.fetch(:signatures, nil) @icon_url = kwargs.fetch(:icon_url, nil) end |
Instance Attribute Details
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities.
10 11 12 |
# File 'lib/a2a/agent_card.rb', line 10 def capabilities @capabilities end |
#default_input_modes ⇒ Object (readonly)
Returns the value of attribute default_input_modes.
10 11 12 |
# File 'lib/a2a/agent_card.rb', line 10 def default_input_modes @default_input_modes end |
#default_output_modes ⇒ Object (readonly)
Returns the value of attribute default_output_modes.
10 11 12 |
# File 'lib/a2a/agent_card.rb', line 10 def default_output_modes @default_output_modes end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
10 11 12 |
# File 'lib/a2a/agent_card.rb', line 10 def description @description end |
#documentation_url ⇒ Object (readonly)
Returns the value of attribute documentation_url.
10 11 12 |
# File 'lib/a2a/agent_card.rb', line 10 def documentation_url @documentation_url end |
#icon_url ⇒ Object (readonly)
Returns the value of attribute icon_url.
10 11 12 |
# File 'lib/a2a/agent_card.rb', line 10 def icon_url @icon_url end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/a2a/agent_card.rb', line 10 def name @name end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
10 11 12 |
# File 'lib/a2a/agent_card.rb', line 10 def provider @provider end |
#security_requirements ⇒ Object (readonly)
Returns the value of attribute security_requirements.
10 11 12 |
# File 'lib/a2a/agent_card.rb', line 10 def security_requirements @security_requirements end |
#security_schemes ⇒ Object (readonly)
Returns the value of attribute security_schemes.
10 11 12 |
# File 'lib/a2a/agent_card.rb', line 10 def security_schemes @security_schemes end |
#signatures ⇒ Object (readonly)
Returns the value of attribute signatures.
10 11 12 |
# File 'lib/a2a/agent_card.rb', line 10 def signatures @signatures end |
#skills ⇒ Object (readonly)
Returns the value of attribute skills.
10 11 12 |
# File 'lib/a2a/agent_card.rb', line 10 def skills @skills end |
#supported_interfaces ⇒ Object (readonly)
Returns the value of attribute supported_interfaces.
10 11 12 |
# File 'lib/a2a/agent_card.rb', line 10 def supported_interfaces @supported_interfaces end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/a2a/agent_card.rb', line 10 def version @version end |
Class Method Details
.from_h(hash) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/a2a/agent_card.rb', line 41 def self.from_h(hash) new( name: hash.fetch("name"), description: hash.fetch("description"), version: hash.fetch("version"), supported_interfaces: hash.fetch("supportedInterfaces").map { AgentInterface.from_h(it) }, capabilities: AgentCapabilities.from_h(hash.fetch("capabilities")), skills: hash.fetch("skills").map { AgentSkill.from_h(it) }, security_schemes: (hash["securitySchemes"] || {}).transform_values { SecurityScheme.from_h(it) }, security_requirements: hash["security"], default_input_modes: hash.fetch("defaultInputModes"), default_output_modes: hash.fetch("defaultOutputModes"), provider: hash["provider"] && AgentProvider.from_h(hash["provider"]), documentation_url: hash["documentationUrl"], icon_url: hash["iconUrl"], signatures: hash["signatures"]&.map { Signature.from_h(it) } ) end |
Instance Method Details
#canonical_json ⇒ Object
§8.4.1 — RFC 8785 canonical JSON: to_h with “signatures” excluded and keys sorted recursively. Used as the payload for JWS signing/verification.
67 68 69 |
# File 'lib/a2a/agent_card.rb', line 67 def canonical_json JSON.generate(sort_keys_recursive(to_h.except("signatures"))) end |
#preferred_interface(preference: [AgentInterface::JSONRPC, AgentInterface::HTTP_JSON]) ⇒ Object
§5.2 — returns the first interface whose protocolBinding the caller supports, preserving the agent’s declared preference order (index 0 = most preferred).
73 74 75 |
# File 'lib/a2a/agent_card.rb', line 73 def preferred_interface(preference: [AgentInterface::JSONRPC, AgentInterface::HTTP_JSON]) supported_interfaces.find { |i| preference.include?(i.protocol_binding) } end |
#to_h ⇒ Object
rubocop:enable Metrics/AbcSize, Metrics/MethodLength
61 62 63 |
# File 'lib/a2a/agent_card.rb', line 61 def to_h required_fields.merge(optional_fields).compact end |