Class: LLM::A2A::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/a2a/card.rb,
lib/llm/a2a/card/skill.rb,
lib/llm/a2a/card/provider.rb,
lib/llm/a2a/card/interface.rb,
lib/llm/a2a/card/capabilities.rb

Overview

Represents an A2A Agent Card — a self-describing manifest for an agent that provides metadata including the agent's identity, capabilities, skills, supported communication methods, and security requirements.

Agent Cards are published at /.well-known/agent-card.json and allow clients to discover an agent's capabilities before interacting.

Examples:

a2a = LLM::A2A.rest(url: "https://agent.example.com")
card = a2a.card
puts card.name          # => "GeoSpatial Route Planner Agent"
puts card.description   # => "Provides advanced route planning..."
card.skills.each { |s| puts "#{s.name}: #{s.description}" }

Defined Under Namespace

Classes: Capabilities, Interface, Provider, Skill

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Card

Returns a new instance of Card.

Parameters:

  • data (Hash)

    The raw Agent Card JSON data



27
28
29
# File 'lib/llm/a2a/card.rb', line 27

def initialize(data)
  @data = LLM::Object.from(data)
end

Instance Method Details

#inspectString

Returns:

  • (String)


140
141
142
# File 'lib/llm/a2a/card.rb', line 140

def inspect
  "#<#{LLM::Utils.object_id(self)} @name=#{name.inspect} @skills=#{skills.size}>"
end

#nameString

Returns a human-readable name for the agent.

Returns:

  • (String)


34
35
36
# File 'lib/llm/a2a/card.rb', line 34

def name
  @data.name
end

#descriptionString

Returns a human-readable description of the agent.

Returns:

  • (String)


41
42
43
# File 'lib/llm/a2a/card.rb', line 41

def description
  @data.description
end

#versionString

Returns the agent version.

Returns:

  • (String)


48
49
50
# File 'lib/llm/a2a/card.rb', line 48

def version
  @data.version
end

#protocol_versionString?

Returns the advertised A2A protocol version.

Returns:

  • (String, nil)


55
56
57
# File 'lib/llm/a2a/card.rb', line 55

def protocol_version
  @data.protocolVersion || @data.protocol_version
end

#documentation_urlString?

Returns the documentation URL, when present.

Returns:

  • (String, nil)


62
63
64
# File 'lib/llm/a2a/card.rb', line 62

def documentation_url
  @data.documentationUrl || @data.documentation_url
end

#icon_urlString?

Returns the icon URL, when present.

Returns:

  • (String, nil)


69
70
71
# File 'lib/llm/a2a/card.rb', line 69

def icon_url
  @data.iconUrl || @data.icon_url
end

#skillsArray<LLM::A2A::Card::Skill>

Returns the skills provided by the agent.

Returns:



76
77
78
# File 'lib/llm/a2a/card.rb', line 76

def skills
  @skills ||= (@data.skills || []).map { Skill.new(_1) }
end

#interfacesArray<LLM::A2A::Card::Interface>

Returns the interfaces supported by the agent.

Returns:



83
84
85
# File 'lib/llm/a2a/card.rb', line 83

def interfaces
  @interfaces ||= (@data.supportedInterfaces || @data.supported_interfaces || []).map { Interface.new(_1) }
end

#capabilitiesLLM::A2A::Card::Capabilities?

Returns the optional capabilities declaration.



90
91
92
93
# File 'lib/llm/a2a/card.rb', line 90

def capabilities
  raw = @data.capabilities
  raw ? Capabilities.new(raw) : nil
end

#signaturesArray<LLM::Object>

Returns the agent card signatures.

Returns:



98
99
100
# File 'lib/llm/a2a/card.rb', line 98

def signatures
  @signatures ||= (@data.signatures || []).map { LLM::Object.from(_1) }
end

#security_schemesHash<String, Hash>?

Returns the security scheme definitions.

Returns:

  • (Hash<String, Hash>, nil)


105
106
107
# File 'lib/llm/a2a/card.rb', line 105

def security_schemes
  @data.securitySchemes || @data.security_schemes
end

#security_requirementsArray<Hash>?

Returns the security requirements.

Returns:

  • (Array<Hash>, nil)


112
113
114
# File 'lib/llm/a2a/card.rb', line 112

def security_requirements
  @data.security || @data.security_requirements
end

#providerLLM::A2A::Card::Provider?

Returns the declared provider information.

Returns:



119
120
121
122
# File 'lib/llm/a2a/card.rb', line 119

def provider
  raw = @data.provider
  raw ? Provider.new(raw) : nil
end

#default_input_modesArray<String>

Returns the default input media types.

Returns:

  • (Array<String>)


127
128
129
# File 'lib/llm/a2a/card.rb', line 127

def default_input_modes
  @data.defaultInputModes || @data.default_input_modes || []
end

#default_output_modesArray<String>

Returns the default output media types.

Returns:

  • (Array<String>)


134
135
136
# File 'lib/llm/a2a/card.rb', line 134

def default_output_modes
  @data.defaultOutputModes || @data.default_output_modes || []
end