Class: SimpleAcp::Models::AgentManifest
- Defined in:
- lib/simple_acp/models/agent_manifest.rb
Overview
Describes agent capabilities for discovery.
Contains the metadata needed to advertise an agent's capabilities, including what content types it accepts and produces.
Instance Attribute Summary collapse
-
#description ⇒ String?
readonly
Human-readable description.
-
#input_content_types ⇒ Array<String>
readonly
Accepted MIME types (default: ["text/plain"]).
-
#metadata ⇒ Metadata?
readonly
Additional metadata.
-
#name ⇒ String
readonly
Agent name (RFC 1123 DNS label format).
-
#output_content_types ⇒ Array<String>
readonly
Produced MIME types (default: ["text/plain"]).
-
#status ⇒ AgentStatus?
readonly
Status metrics.
Class Method Summary collapse
-
.from_hash(hash) ⇒ AgentManifest?
Create from a hash (JSON deserialization).
Instance Method Summary collapse
-
#accepts_content_type?(content_type) ⇒ Boolean
Check if the agent accepts a content type.
-
#initialize(**kwargs) ⇒ AgentManifest
constructor
A new instance of AgentManifest.
-
#produces_content_type?(content_type) ⇒ Boolean
Check if the agent produces a content type.
-
#valid? ⇒ Boolean
Validate the manifest.
Methods inherited from Base
#==, attribute, attributes, #hash, own_attributes, #to_h, #to_json
Constructor Details
#initialize(**kwargs) ⇒ AgentManifest
Returns a new instance of AgentManifest.
34 35 36 37 38 |
# File 'lib/simple_acp/models/agent_manifest.rb', line 34 def initialize(**kwargs) super @input_content_types ||= ["text/plain"] @output_content_types ||= ["text/plain"] end |
Instance Attribute Details
#description ⇒ String? (readonly)
Returns human-readable description.
16 |
# File 'lib/simple_acp/models/agent_manifest.rb', line 16 attribute :description |
#input_content_types ⇒ Array<String> (readonly)
Returns accepted MIME types (default: ["text/plain"]).
24 |
# File 'lib/simple_acp/models/agent_manifest.rb', line 24 attribute :input_content_types, default: -> { ["text/plain"] } |
#metadata ⇒ Metadata? (readonly)
Returns additional metadata.
20 |
# File 'lib/simple_acp/models/agent_manifest.rb', line 20 attribute :metadata |
#name ⇒ String (readonly)
Returns agent name (RFC 1123 DNS label format).
12 |
# File 'lib/simple_acp/models/agent_manifest.rb', line 12 attribute :name, required: true |
#output_content_types ⇒ Array<String> (readonly)
Returns produced MIME types (default: ["text/plain"]).
28 |
# File 'lib/simple_acp/models/agent_manifest.rb', line 28 attribute :output_content_types, default: -> { ["text/plain"] } |
#status ⇒ AgentStatus? (readonly)
Returns status metrics.
32 |
# File 'lib/simple_acp/models/agent_manifest.rb', line 32 attribute :status |
Class Method Details
.from_hash(hash) ⇒ AgentManifest?
Create from a hash (JSON deserialization).
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/simple_acp/models/agent_manifest.rb', line 44 def self.from_hash(hash) return nil if hash.nil? instance = super if hash["metadata"] || hash[:metadata] instance. = Metadata.from_hash(hash["metadata"] || hash[:metadata]) end if hash["status"] || hash[:status] instance.status = AgentStatus.from_hash(hash["status"] || hash[:status]) end instance end |
Instance Method Details
#accepts_content_type?(content_type) ⇒ Boolean
Check if the agent accepts a content type.
64 65 66 67 68 69 70 |
# File 'lib/simple_acp/models/agent_manifest.rb', line 64 def accepts_content_type?(content_type) return true if @input_content_types.include?("*/*") @input_content_types.any? do |accepted| matches_content_type?(accepted, content_type) end end |
#produces_content_type?(content_type) ⇒ Boolean
Check if the agent produces a content type.
76 77 78 79 80 81 82 |
# File 'lib/simple_acp/models/agent_manifest.rb', line 76 def produces_content_type?(content_type) return true if @output_content_types.include?("*/*") @output_content_types.any? do |produced| matches_content_type?(produced, content_type) end end |
#valid? ⇒ Boolean
Validate the manifest.
87 88 89 90 91 92 93 |
# File 'lib/simple_acp/models/agent_manifest.rb', line 87 def valid? return false unless Types.valid_agent_name?(@name) return false if @input_content_types.empty? return false if @output_content_types.empty? true end |