Class: A2A::Types::AgentInterface

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/a2a/types/agent_card.rb

Overview

Represents an agent interface

Interfaces define the transport protocols and URLs that can be used to communicate with the agent.

Examples:

Creating an interface

interface = A2A::Types::AgentInterface.new(
  transport: "JSONRPC",
  url: "https://example.com/agent/rpc"
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#==, #camelize, from_h, from_json, #hash, #to_h, #to_json, underscore, #valid?, #validate_array_type, #validate_inclusion, #validate_required, #validate_type

Constructor Details

#initialize(transport:, url:) ⇒ AgentInterface

Initialize a new agent interface

Parameters:

  • Transport protocol (JSONRPC, GRPC, HTTP+JSON)

  • Interface URL



395
396
397
398
399
# File 'lib/a2a/types/agent_card.rb', line 395

def initialize(transport:, url:)
  @transport = transport
  @url = url
  validate!
end

Instance Attribute Details

#transportObject (readonly)

Returns the value of attribute transport.



388
389
390
# File 'lib/a2a/types/agent_card.rb', line 388

def transport
  @transport
end

#urlObject (readonly)

Returns the value of attribute url.



388
389
390
# File 'lib/a2a/types/agent_card.rb', line 388

def url
  @url
end

Instance Method Details

#secure?Boolean

Check if this is a secure interface (HTTPS)

Returns:

  • True if the URL uses HTTPS



414
415
416
# File 'lib/a2a/types/agent_card.rb', line 414

def secure?
  @url.start_with?("https://")
end

#uses_transport?(transport_type) ⇒ Boolean

Check if this interface uses the specified transport

Parameters:

  • The transport type to check

Returns:

  • True if this interface uses the transport



406
407
408
# File 'lib/a2a/types/agent_card.rb', line 406

def uses_transport?(transport_type)
  @transport == transport_type
end

#validate!Object (private)



420
421
422
423
424
425
# File 'lib/a2a/types/agent_card.rb', line 420

def validate!
  validate_required(:transport, :url)
  validate_inclusion(:transport, VALID_TRANSPORTS)
  validate_type(:url, String)
  validate_url_format
end

#validate_url_formatObject (private)

Validate URL format



429
430
431
432
433
434
# File 'lib/a2a/types/agent_card.rb', line 429

def validate_url_format
  uri = URI.parse(@url)
  raise ArgumentError, "url must be a valid HTTP or HTTPS URL" unless uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
rescue URI::InvalidURIError
  raise ArgumentError, "url must be a valid URL"
end