Class: Remitmd::AgentCard
- Inherits:
-
Object
- Object
- Remitmd::AgentCard
- Defined in:
- lib/remitmd/a2a.rb
Overview
A2A agent card parsed from /.well-known/agent-card.json.
Instance Attribute Summary collapse
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#documentation_url ⇒ Object
readonly
Returns the value of attribute documentation_url.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#protocol_version ⇒ Object
readonly
Returns the value of attribute protocol_version.
-
#skills ⇒ Object
readonly
Returns the value of attribute skills.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#x402 ⇒ Object
readonly
Returns the value of attribute x402.
Class Method Summary collapse
-
.discover(base_url) ⇒ AgentCard
Fetch and parse the A2A agent card from
base_url/.well-known/agent-card.json.
Instance Method Summary collapse
-
#initialize(data) ⇒ AgentCard
constructor
A new instance of AgentCard.
Constructor Details
#initialize(data) ⇒ AgentCard
Returns a new instance of AgentCard.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/remitmd/a2a.rb', line 19 def initialize(data) @protocol_version = data["protocolVersion"] || "0.6" @name = data["name"].to_s @description = data["description"].to_s @url = data["url"].to_s @version = data["version"].to_s @documentation_url = data["documentationUrl"].to_s @capabilities = data["capabilities"] || {} @skills = (data["skills"] || []).map do |s| AgentSkill.new( id: s["id"].to_s, name: s["name"].to_s, description: s["description"].to_s, tags: s["tags"] || [] ) end @x402 = data["x402"] || {} end |
Instance Attribute Details
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities.
16 17 18 |
# File 'lib/remitmd/a2a.rb', line 16 def capabilities @capabilities end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
16 17 18 |
# File 'lib/remitmd/a2a.rb', line 16 def description @description end |
#documentation_url ⇒ Object (readonly)
Returns the value of attribute documentation_url.
16 17 18 |
# File 'lib/remitmd/a2a.rb', line 16 def documentation_url @documentation_url end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/remitmd/a2a.rb', line 16 def name @name end |
#protocol_version ⇒ Object (readonly)
Returns the value of attribute protocol_version.
16 17 18 |
# File 'lib/remitmd/a2a.rb', line 16 def protocol_version @protocol_version end |
#skills ⇒ Object (readonly)
Returns the value of attribute skills.
16 17 18 |
# File 'lib/remitmd/a2a.rb', line 16 def skills @skills end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
16 17 18 |
# File 'lib/remitmd/a2a.rb', line 16 def url @url end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
16 17 18 |
# File 'lib/remitmd/a2a.rb', line 16 def version @version end |
#x402 ⇒ Object (readonly)
Returns the value of attribute x402.
16 17 18 |
# File 'lib/remitmd/a2a.rb', line 16 def x402 @x402 end |
Class Method Details
.discover(base_url) ⇒ AgentCard
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/remitmd/a2a.rb', line 46 def self.discover(base_url) url = URI("#{base_url.chomp("/")}/.well-known/agent-card.json") response = Net::HTTP.start(url.host, url.port, use_ssl: url.scheme == "https") do |http| req = Net::HTTP::Get.new(url) req["Accept"] = "application/json" http.request(req) end raise "Agent card discovery failed: HTTP #{response.code}" unless response.is_a?(Net::HTTPSuccess) new(JSON.parse(response.body)) end |