Class: Agentic::CapabilitySpecification
- Inherits:
-
Object
- Object
- Agentic::CapabilitySpecification
- Defined in:
- lib/agentic/capability_specification.rb
Overview
Defines the specification for an agent capability
Instance Attribute Summary collapse
-
#dependencies ⇒ Array<Hash>
readonly
The dependencies of the capability.
-
#description ⇒ String
readonly
Description of the capability.
-
#inputs ⇒ Hash
readonly
The required inputs for the capability.
-
#name ⇒ String
readonly
The name of the capability.
-
#outputs ⇒ Hash
readonly
The expected outputs from the capability.
-
#version ⇒ String
readonly
The version of the capability.
Class Method Summary collapse
-
.from_h(hash) ⇒ CapabilitySpecification
Create from a hash representation.
Instance Method Summary collapse
-
#compatible_with?(other) ⇒ Boolean
Check if this capability is compatible with another capability.
-
#initialize(name:, description:, version:, inputs: {}, outputs: {}, dependencies: []) ⇒ CapabilitySpecification
constructor
Initialize a new capability specification.
-
#requirements_description ⇒ String
Get the capability requirements as a human-readable string.
-
#to_h ⇒ Hash
Convert to a hash representation.
Constructor Details
#initialize(name:, description:, version:, inputs: {}, outputs: {}, dependencies: []) ⇒ CapabilitySpecification
Initialize a new capability specification
21 22 23 24 25 26 27 28 |
# File 'lib/agentic/capability_specification.rb', line 21 def initialize(name:, description:, version:, inputs: {}, outputs: {}, dependencies: []) @name = name @description = description @version = version @inputs = inputs @outputs = outputs @dependencies = dependencies end |
Instance Attribute Details
#dependencies ⇒ Array<Hash> (readonly)
The dependencies of the capability
11 12 13 |
# File 'lib/agentic/capability_specification.rb', line 11 def dependencies @dependencies end |
#description ⇒ String (readonly)
Description of the capability
11 12 13 |
# File 'lib/agentic/capability_specification.rb', line 11 def description @description end |
#inputs ⇒ Hash (readonly)
The required inputs for the capability
11 12 13 |
# File 'lib/agentic/capability_specification.rb', line 11 def inputs @inputs end |
#name ⇒ String (readonly)
The name of the capability
11 12 13 |
# File 'lib/agentic/capability_specification.rb', line 11 def name @name end |
#outputs ⇒ Hash (readonly)
The expected outputs from the capability
11 12 13 |
# File 'lib/agentic/capability_specification.rb', line 11 def outputs @outputs end |
#version ⇒ String (readonly)
The version of the capability
11 12 13 |
# File 'lib/agentic/capability_specification.rb', line 11 def version @version end |
Class Method Details
.from_h(hash) ⇒ CapabilitySpecification
Create from a hash representation
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/agentic/capability_specification.rb', line 72 def self.from_h(hash) new( name: hash[:name] || hash["name"], description: hash[:description] || hash["description"], version: hash[:version] || hash["version"], inputs: hash[:inputs] || hash["inputs"] || {}, outputs: hash[:outputs] || hash["outputs"] || {}, dependencies: hash[:dependencies] || hash["dependencies"] || [] ) end |
Instance Method Details
#compatible_with?(other) ⇒ Boolean
Check if this capability is compatible with another capability
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/agentic/capability_specification.rb', line 33 def compatible_with?(other) return false unless other.is_a?(CapabilitySpecification) return false unless name == other.name # Compare versions using semantic versioning rules # For now, just check for exact match or higher minor version return true if version == other.version begin my_parts = version.split(".").map(&:to_i) other_parts = other.version.split(".").map(&:to_i) # Major version must match return false unless my_parts[0] == other_parts[0] # Our minor version should be >= other's minor version my_parts[1] >= other_parts[1] rescue # If version parsing fails, require exact match false end end |
#requirements_description ⇒ String
Get the capability requirements as a human-readable string
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/agentic/capability_specification.rb', line 85 def requirements_description result = "Capability: #{name} (v#{version})\n" result += "Description: #{description}\n" unless inputs.empty? result += "\nInputs:\n" inputs.each do |name, spec| result += " #{name}: #{spec[:type] || "any"}" result += " (required)" if spec[:required] result += " - #{spec[:description]}" if spec[:description] result += "\n" end end unless outputs.empty? result += "\nOutputs:\n" outputs.each do |name, spec| result += " #{name}: #{spec[:type] || "any"}" result += " - #{spec[:description]}" if spec[:description] result += "\n" end end unless dependencies.empty? result += "\nDependencies:\n" dependencies.each do |dep| result += " #{dep[:name]} (v#{dep[:version] || "any"})\n" end end result end |
#to_h ⇒ Hash
Convert to a hash representation
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/agentic/capability_specification.rb', line 58 def to_h { name: @name, description: @description, version: @version, inputs: @inputs, outputs: @outputs, dependencies: @dependencies } end |