Module: SolidAgent::AgentManifest
- Defined in:
- lib/solid_agent/agent_manifest.rb,
lib/solid_agent/agent_manifest/tool.rb,
lib/solid_agent/agent_manifest/errors.rb,
lib/solid_agent/agent_manifest/manifest.rb,
lib/solid_agent/agent_manifest/resource.rb,
lib/solid_agent/agent_manifest/validator.rb,
lib/solid_agent/agent_manifest/picoschema.rb,
lib/solid_agent/agent_manifest/input_schema.rb,
lib/solid_agent/agent_manifest/agent_builder.rb,
lib/solid_agent/agent_manifest/registry/auth.rb,
lib/solid_agent/agent_manifest/parser_registry.rb,
lib/solid_agent/agent_manifest/registry/client.rb,
lib/solid_agent/agent_manifest/exporter_registry.rb,
lib/solid_agent/agent_manifest/parsers/base_parser.rb,
lib/solid_agent/agent_manifest/parsers/crewai_parser.rb,
lib/solid_agent/agent_manifest/exporters/base_exporter.rb,
lib/solid_agent/agent_manifest/parsers/agent_md_parser.rb,
lib/solid_agent/agent_manifest/parsers/dotprompt_parser.rb,
lib/solid_agent/agent_manifest/exporters/crewai_exporter.rb,
lib/solid_agent/agent_manifest/exporters/agent_md_exporter.rb,
lib/solid_agent/agent_manifest/exporters/dotprompt_exporter.rb,
lib/solid_agent/agent_manifest/parsers/github_prompt_parser.rb
Overview
AgentManifest provides a unified interface for working with agent definition files.
Supports multiple formats:
.agent.md- Native format with full feature support.prompt- Google Dotprompt formatagents.yaml- CrewAI format.prompt.md- GitHub Copilot format
Defined Under Namespace
Modules: Exporters, Parsers, Registry Classes: AgentBuilder, Error, ExportError, ExporterRegistry, InputSchema, Manifest, ParseError, ParserRegistry, Picoschema, RegistryError, Resource, SchemaError, Tool, UnknownFormatError, ValidationError, Validator
Class Method Summary collapse
-
.build(manifest, base_class: nil, class_name: nil) ⇒ Class
Build agent class from manifest.
-
.build_instance(manifest, params: {}, **options) ⇒ Object
Build agent instance from manifest.
-
.checksum(content) ⇒ String
Generate checksum for any content.
-
.convert(input_path, output_format, output_path = nil) ⇒ String
Convert a manifest file between formats.
-
.detect_format(path) ⇒ Symbol
Detect the format of a file.
-
.export(manifest, format, **options) ⇒ String
Export a manifest to a format string.
-
.export_to_file(manifest, format, path, **options) ⇒ String
Export a manifest to a file.
-
.exporter_formats ⇒ Array<Symbol>
List supported exporter formats.
-
.from_file(path, format: nil) ⇒ Manifest
Load manifest from file.
-
.from_hash(hash) ⇒ Manifest
Load manifest from Hash.
-
.from_json(json_string) ⇒ Manifest
Load manifest from JSON string.
-
.from_string(content, format:) ⇒ Manifest
Load manifest from string content.
-
.from_url(url, format: nil) ⇒ Manifest
Load manifest from URL.
-
.from_yaml(yaml_string) ⇒ Manifest
Load manifest from YAML string.
-
.load(source, format: nil) ⇒ Manifest
Load manifest from any source with auto-detection.
-
.load_agent(path, base_class: nil, class_name: nil) ⇒ Class
Load an agent class from a manifest file.
-
.load_agent_instance(path, params: {}, **options) ⇒ Object
Load and instantiate an agent from a manifest file.
-
.parse(path, format: nil) ⇒ Manifest
Parse a manifest file.
-
.parse_string(content, format:) ⇒ Manifest
Parse manifest content from a string.
-
.parser_formats ⇒ Array<Symbol>
List supported parser formats.
-
.provenance(manifest) ⇒ Hash
Generate provenance record for a manifest.
-
.valid?(path_or_manifest, strict: false) ⇒ Boolean
Check if a manifest is valid.
-
.validate(path_or_manifest, strict: false) ⇒ Array<String>
Validate a manifest file or object.
-
.validate!(path_or_manifest, strict: false) ⇒ Manifest
Validate and raise if invalid.
Class Method Details
.build(manifest, base_class: nil, class_name: nil) ⇒ Class
Build agent class from manifest
157 158 159 |
# File 'lib/solid_agent/agent_manifest.rb', line 157 def build(manifest, base_class: nil, class_name: nil) AgentBuilder.build(manifest, base_class: base_class, class_name: class_name) end |
.build_instance(manifest, params: {}, **options) ⇒ Object
Build agent instance from manifest
166 167 168 |
# File 'lib/solid_agent/agent_manifest.rb', line 166 def build_instance(manifest, params: {}, **) AgentBuilder.build_instance(manifest, params: params, **) end |
.checksum(content) ⇒ String
Generate checksum for any content
178 179 180 181 182 183 184 185 |
# File 'lib/solid_agent/agent_manifest.rb', line 178 def checksum(content) data = case content when String then content when Hash then content.to_json else content.to_s end Digest::MD5.hexdigest(data) end |
.convert(input_path, output_format, output_path = nil) ⇒ String
Convert a manifest file between formats
255 256 257 |
# File 'lib/solid_agent/agent_manifest.rb', line 255 def convert(input_path, output_format, output_path = nil) ExporterRegistry.convert(input_path, output_format, output_path) end |
.detect_format(path) ⇒ Symbol
Detect the format of a file
330 331 332 |
# File 'lib/solid_agent/agent_manifest.rb', line 330 def detect_format(path) ParserRegistry.detect_format(path) end |
.export(manifest, format, **options) ⇒ String
Export a manifest to a format string
234 235 236 |
# File 'lib/solid_agent/agent_manifest.rb', line 234 def export(manifest, format, **) ExporterRegistry.export(manifest, format, **) end |
.export_to_file(manifest, format, path, **options) ⇒ String
Export a manifest to a file
245 246 247 |
# File 'lib/solid_agent/agent_manifest.rb', line 245 def export_to_file(manifest, format, path, **) ExporterRegistry.export_to_file(manifest, format, path, **) end |
.exporter_formats ⇒ Array<Symbol>
List supported exporter formats
321 322 323 |
# File 'lib/solid_agent/agent_manifest.rb', line 321 def exporter_formats ExporterRegistry.formats end |
.from_file(path, format: nil) ⇒ Manifest
Load manifest from file
113 114 115 |
# File 'lib/solid_agent/agent_manifest.rb', line 113 def from_file(path, format: nil) parse(path, format: format) end |
.from_hash(hash) ⇒ Manifest
Load manifest from Hash
147 148 149 |
# File 'lib/solid_agent/agent_manifest.rb', line 147 def from_hash(hash) Manifest.new(**hash.transform_keys(&:to_sym)) end |
.from_json(json_string) ⇒ Manifest
Load manifest from JSON string
130 131 132 |
# File 'lib/solid_agent/agent_manifest.rb', line 130 def from_json(json_string) from_hash(JSON.parse(json_string, symbolize_names: true)) end |
.from_string(content, format:) ⇒ Manifest
Load manifest from string content
122 123 124 |
# File 'lib/solid_agent/agent_manifest.rb', line 122 def from_string(content, format:) parse_string(content, format: format) end |
.from_url(url, format: nil) ⇒ Manifest
Load manifest from URL
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/solid_agent/agent_manifest.rb', line 91 def from_url(url, format: nil) require "net/http" require "uri" uri = URI.parse(url) response = Net::HTTP.get_response(uri) unless response.is_a?(Net::HTTPSuccess) raise SolidAgent::LoadError, "Failed to fetch #{url}: #{response.code}" end format ||= detect_format_from_url(url) || detect_format_from_content_type(response) manifest = from_string(response.body, format: format) manifest.source_path = url manifest end |
.from_yaml(yaml_string) ⇒ Manifest
Load manifest from YAML string
138 139 140 141 |
# File 'lib/solid_agent/agent_manifest.rb', line 138 def from_yaml(yaml_string) require "yaml" from_hash(YAML.safe_load(yaml_string, symbolize_names: true, permitted_classes: [Symbol])) end |
.load(source, format: nil) ⇒ Manifest
Load manifest from any source with auto-detection
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/solid_agent/agent_manifest.rb', line 71 def load(source, format: nil) case source when Hash from_hash(source) when ->(s) { s.is_a?(String) && s.match?(%r{\Ahttps?://}) } from_url(source, format: format) when ->(s) { s.is_a?(String) && File.exist?(s) } from_file(source, format: format) when String from_string(source, format: format || detect_string_format(source)) else raise ArgumentError, "Unknown source type: #{source.class}" end end |
.load_agent(path, base_class: nil, class_name: nil) ⇒ Class
Load an agent class from a manifest file
265 266 267 268 |
# File 'lib/solid_agent/agent_manifest.rb', line 265 def load_agent(path, base_class: nil, class_name: nil) manifest = parse(path) AgentBuilder.build(manifest, base_class: base_class, class_name: class_name) end |
.load_agent_instance(path, params: {}, **options) ⇒ Object
Load and instantiate an agent from a manifest file
276 277 278 279 |
# File 'lib/solid_agent/agent_manifest.rb', line 276 def load_agent_instance(path, params: {}, **) manifest = parse(path) AgentBuilder.build_instance(manifest, params: params, **) end |
.parse(path, format: nil) ⇒ Manifest
Parse a manifest file
215 216 217 |
# File 'lib/solid_agent/agent_manifest.rb', line 215 def parse(path, format: nil) ParserRegistry.parse(path, format: format) end |
.parse_string(content, format:) ⇒ Manifest
Parse manifest content from a string
224 225 226 |
# File 'lib/solid_agent/agent_manifest.rb', line 224 def parse_string(content, format:) ParserRegistry.parse_string(content, format: format) end |
.parser_formats ⇒ Array<Symbol>
List supported parser formats
314 315 316 |
# File 'lib/solid_agent/agent_manifest.rb', line 314 def parser_formats ParserRegistry.formats end |
.provenance(manifest) ⇒ Hash
Generate provenance record for a manifest
191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/solid_agent/agent_manifest.rb', line 191 def provenance(manifest) { manifest_checksum: checksum(manifest.to_h), instructions_checksum: manifest.instructions ? checksum(manifest.instructions) : nil, model: manifest.model, version: manifest.version, source_path: manifest.source_path, source_format: manifest.source_format, generated_at: Time.now.iso8601, tools: manifest.tools&.map { |t| { name: t.name, checksum: checksum(t.to_h) } } }.compact end |
.valid?(path_or_manifest, strict: false) ⇒ Boolean
Check if a manifest is valid
296 297 298 |
# File 'lib/solid_agent/agent_manifest.rb', line 296 def valid?(path_or_manifest, strict: false) validate(path_or_manifest, strict: strict).empty? end |
.validate(path_or_manifest, strict: false) ⇒ Array<String>
Validate a manifest file or object
286 287 288 289 |
# File 'lib/solid_agent/agent_manifest.rb', line 286 def validate(path_or_manifest, strict: false) manifest = path_or_manifest.is_a?(String) ? parse(path_or_manifest) : path_or_manifest Validator.validate(manifest, strict: strict) end |
.validate!(path_or_manifest, strict: false) ⇒ Manifest
Validate and raise if invalid
306 307 308 309 |
# File 'lib/solid_agent/agent_manifest.rb', line 306 def validate!(path_or_manifest, strict: false) manifest = path_or_manifest.is_a?(String) ? parse(path_or_manifest) : path_or_manifest Validator.validate!(manifest, strict: strict) end |