Class: A2A::AgentSkill

Inherits:
Object
  • Object
show all
Defined in:
lib/a2a/agent_skill.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, description:, tags:, **kwargs) ⇒ AgentSkill

Returns a new instance of AgentSkill.

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/a2a/agent_skill.rb', line 7

def initialize(id:, name:, description:, tags:, **kwargs)
  raise ArgumentError, "tags must contain at least one element" if Array(tags).empty?

  @id = id
  @name = name
  @description = description
  @tags = tags
  @examples = kwargs[:examples]
  @input_modes = kwargs[:input_modes]
  @output_modes = kwargs[:output_modes]
  @security_requirements = kwargs[:security_requirements]
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/a2a/agent_skill.rb', line 5

def description
  @description
end

#examplesObject (readonly)

Returns the value of attribute examples.



5
6
7
# File 'lib/a2a/agent_skill.rb', line 5

def examples
  @examples
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/a2a/agent_skill.rb', line 5

def id
  @id
end

#input_modesObject (readonly)

Returns the value of attribute input_modes.



5
6
7
# File 'lib/a2a/agent_skill.rb', line 5

def input_modes
  @input_modes
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/a2a/agent_skill.rb', line 5

def name
  @name
end

#output_modesObject (readonly)

Returns the value of attribute output_modes.



5
6
7
# File 'lib/a2a/agent_skill.rb', line 5

def output_modes
  @output_modes
end

#security_requirementsObject (readonly)

Returns the value of attribute security_requirements.



5
6
7
# File 'lib/a2a/agent_skill.rb', line 5

def security_requirements
  @security_requirements
end

#tagsObject (readonly)

Returns the value of attribute tags.



5
6
7
# File 'lib/a2a/agent_skill.rb', line 5

def tags
  @tags
end

Class Method Details

.from_h(hash) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/a2a/agent_skill.rb', line 20

def self.from_h(hash)
  new(
    id: hash.fetch("id"),
    name: hash.fetch("name"),
    description: hash.fetch("description"),
    tags: hash.fetch("tags"),
    examples: hash["examples"],
    input_modes: hash["inputModes"],
    output_modes: hash["outputModes"],
    security_requirements: hash["securityRequirements"]&.map { SecurityRequirement.from_h(_1) }
  )
end

Instance Method Details

#to_hObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/a2a/agent_skill.rb', line 33

def to_h
  {
    "id" => id,
    "name" => name,
    "description" => description,
    "tags" => tags,
    "examples" => examples,
    "inputModes" => input_modes,
    "outputModes" => output_modes,
    "securityRequirements" => security_requirements&.map(&:to_h)
  }.compact
end