Class: A2A::Types::AgentSkill
- Defined in:
- lib/a2a/types/agent_card.rb
Overview
Represents an agent skill
Skills define specific capabilities that an agent can perform, including supported input/output modes and security requirements.
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#input_modes ⇒ Object
readonly
Returns the value of attribute input_modes.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output_modes ⇒ Object
readonly
Returns the value of attribute output_modes.
-
#security ⇒ Object
readonly
Returns the value of attribute security.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
-
#initialize(id:, name:, description:, tags: nil, examples: nil, input_modes: nil, output_modes: nil, security: nil) ⇒ AgentSkill
constructor
Initialize a new agent skill.
-
#requires_security?(requirement) ⇒ Boolean
Check if the skill has a specific security requirement.
-
#supports_input_mode?(mode) ⇒ Boolean
Check if the skill supports a specific input mode.
-
#supports_output_mode?(mode) ⇒ Boolean
Check if the skill supports a specific output mode.
- #validate! ⇒ Object private
-
#validate_examples ⇒ Object
private
Validate examples structure.
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(id:, name:, description:, tags: nil, examples: nil, input_modes: nil, output_modes: nil, security: nil) ⇒ AgentSkill
Initialize a new agent skill
220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/a2a/types/agent_card.rb', line 220 def initialize(id:, name:, description:, tags: nil, examples: nil, input_modes: nil, output_modes: nil, security: nil) @id = id @name = name @description = description @tags = @examples = examples @input_modes = input_modes @output_modes = output_modes @security = security validate! end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
207 208 209 |
# File 'lib/a2a/types/agent_card.rb', line 207 def description @description end |
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
207 208 209 |
# File 'lib/a2a/types/agent_card.rb', line 207 def examples @examples end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
207 208 209 |
# File 'lib/a2a/types/agent_card.rb', line 207 def id @id end |
#input_modes ⇒ Object (readonly)
Returns the value of attribute input_modes.
207 208 209 |
# File 'lib/a2a/types/agent_card.rb', line 207 def input_modes @input_modes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
207 208 209 |
# File 'lib/a2a/types/agent_card.rb', line 207 def name @name end |
#output_modes ⇒ Object (readonly)
Returns the value of attribute output_modes.
207 208 209 |
# File 'lib/a2a/types/agent_card.rb', line 207 def output_modes @output_modes end |
#security ⇒ Object (readonly)
Returns the value of attribute security.
207 208 209 |
# File 'lib/a2a/types/agent_card.rb', line 207 def security @security end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
207 208 209 |
# File 'lib/a2a/types/agent_card.rb', line 207 def @tags end |
Instance Method Details
#requires_security?(requirement) ⇒ Boolean
Check if the skill has a specific security requirement
261 262 263 264 265 |
# File 'lib/a2a/types/agent_card.rb', line 261 def requires_security?(requirement) return false if @security.nil? @security.include?(requirement) end |
#supports_input_mode?(mode) ⇒ Boolean
Check if the skill supports a specific input mode
239 240 241 242 243 |
# File 'lib/a2a/types/agent_card.rb', line 239 def supports_input_mode?(mode) return true if @input_modes.nil? # nil means all modes supported @input_modes.include?(mode) end |
#supports_output_mode?(mode) ⇒ Boolean
Check if the skill supports a specific output mode
250 251 252 253 254 |
# File 'lib/a2a/types/agent_card.rb', line 250 def supports_output_mode?(mode) return true if @output_modes.nil? # nil means all modes supported @output_modes.include?(mode) end |
#validate! ⇒ Object (private)
269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/a2a/types/agent_card.rb', line 269 def validate! validate_required(:id, :name, :description) validate_type(:id, String) validate_type(:name, String) validate_type(:description, String) validate_array_type(:tags, String) if @tags validate_array_type(:input_modes, String) if @input_modes validate_array_type(:output_modes, String) if @output_modes validate_array_type(:security, String) if @security validate_examples if @examples end |
#validate_examples ⇒ Object (private)
Validate examples structure
283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/a2a/types/agent_card.rb', line 283 def validate_examples validate_type(:examples, Array) @examples.each_with_index do |example, index| raise ArgumentError, "examples[#{index}] must be a Hash" unless example.is_a?(Hash) # Examples should have at least input or description unless example.key?(:input) || example.key?("input") || example.key?(:description) || example.key?("description") raise ArgumentError, "examples[#{index}] must have input or description" end end end |