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 format
  • agents.yaml - CrewAI format
  • .prompt.md - GitHub Copilot format

Examples:

Parse a manifest file

manifest = SolidAgent::AgentManifest.parse("research_assistant.agent.md")

Parse with auto-detection

manifest = SolidAgent::AgentManifest.parse("agents.yaml")

Export to different format

content = SolidAgent::AgentManifest.export(manifest, :dotprompt)

Convert between formats

SolidAgent::AgentManifest.convert("agent.yaml", :agent_md, "agent.agent.md")

Load as agent class

klass = SolidAgent::AgentManifest.load_agent("research.agent.md")
agent = klass.new

Validate a manifest

errors = SolidAgent::AgentManifest.validate("agent.agent.md")

Load from any source

manifest = SolidAgent::AgentManifest.load("https://example.com/agent.md")
manifest = SolidAgent::AgentManifest.load({ name: "quick", model: "gpt-4o" })

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

Class Method Details

.build(manifest, base_class: nil, class_name: nil) ⇒ Class

Build agent class from manifest

Parameters:

  • manifest (Manifest)

    Manifest to build from

  • base_class (Class) (defaults to: nil)

    Parent class

  • class_name (String) (defaults to: nil)

    Name to register constant as

Returns:

  • (Class)

    Generated agent class



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

Parameters:

  • manifest (Manifest)

    Manifest to build from

  • params (Hash) (defaults to: {})

    Parameters for the agent

Returns:

  • (Object)

    Agent instance



166
167
168
# File 'lib/solid_agent/agent_manifest.rb', line 166

def build_instance(manifest, params: {}, **options)
  AgentBuilder.build_instance(manifest, params: params, **options)
end

.checksum(content) ⇒ String

Generate checksum for any content

Parameters:

  • content (String, Hash, Object)

    Content to checksum

Returns:

  • (String)

    MD5 hex digest



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

Parameters:

  • input_path (String)

    Source file path

  • output_format (Symbol)

    Target format

  • output_path (String, nil) (defaults to: nil)

    Output path (auto-generated if nil)

Returns:

  • (String)

    Output path



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

Parameters:

  • path (String)

    Path to file

Returns:

  • (Symbol)

    Detected format

Raises:



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

Parameters:

  • manifest (Manifest)

    Manifest to export

  • format (Symbol)

    Target format (:agent_md, :dotprompt, :crewai)

  • options (Hash)

    Format-specific options

Returns:

  • (String)

    Exported content



234
235
236
# File 'lib/solid_agent/agent_manifest.rb', line 234

def export(manifest, format, **options)
  ExporterRegistry.export(manifest, format, **options)
end

.export_to_file(manifest, format, path, **options) ⇒ String

Export a manifest to a file

Parameters:

  • manifest (Manifest)

    Manifest to export

  • format (Symbol)

    Target format

  • path (String)

    Output file path

  • options (Hash)

    Format-specific options

Returns:

  • (String)

    The path written to



245
246
247
# File 'lib/solid_agent/agent_manifest.rb', line 245

def export_to_file(manifest, format, path, **options)
  ExporterRegistry.export_to_file(manifest, format, path, **options)
end

.exporter_formatsArray<Symbol>

List supported exporter formats

Returns:

  • (Array<Symbol>)


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

Parameters:

  • path (String)

    Path to manifest file

  • format (Symbol) (defaults to: nil)

    Force format (auto-detected if nil)

Returns:



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

Parameters:

  • hash (Hash)

    Manifest attributes

Returns:



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

Parameters:

  • json_string (String)

    JSON content

Returns:



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

Parameters:

  • content (String)

    Manifest content

  • format (Symbol)

    Content format

Returns:



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

Parameters:

  • url (String)

    URL to fetch manifest from

  • format (Symbol) (defaults to: nil)

    Force format (auto-detected if nil)

Returns:



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

Parameters:

  • yaml_string (String)

    YAML content

Returns:



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

Parameters:

  • source (String, Hash)

    File path, URL, JSON string, YAML string, or Hash

  • format (Symbol) (defaults to: nil)

    Force format (:agent_md, :json, :yaml, :dotprompt, :crewai)

Returns:



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

Parameters:

  • path (String)

    Path to manifest file

  • base_class (Class, nil) (defaults to: nil)

    Base class to inherit from

  • class_name (String, nil) (defaults to: nil)

    Optional class name for registration

Returns:

  • (Class)

    The generated agent class



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

Parameters:

  • path (String)

    Path to manifest file

  • params (Hash) (defaults to: {})

    Parameters to pass to the agent

  • options (Hash)

    Options passed to build

Returns:

  • (Object)

    The instantiated agent



276
277
278
279
# File 'lib/solid_agent/agent_manifest.rb', line 276

def load_agent_instance(path, params: {}, **options)
  manifest = parse(path)
  AgentBuilder.build_instance(manifest, params: params, **options)
end

.parse(path, format: nil) ⇒ Manifest

Parse a manifest file

Parameters:

  • path (String)

    Path to manifest file

  • format (Symbol, nil) (defaults to: nil)

    Force specific format (auto-detected if nil)

Returns:

Raises:



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

Parameters:

  • content (String)

    Manifest content

  • format (Symbol)

    Format of the content

Returns:



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_formatsArray<Symbol>

List supported parser formats

Returns:

  • (Array<Symbol>)


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

Parameters:

  • manifest (Manifest)

    Manifest to generate provenance for

Returns:

  • (Hash)

    Provenance record with checksums



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

Parameters:

  • path_or_manifest (String, Manifest)

    Path to file or Manifest object

  • strict (Boolean) (defaults to: false)

    Enable strict validation

Returns:

  • (Boolean)


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

Parameters:

  • path_or_manifest (String, Manifest)

    Path to file or Manifest object

  • strict (Boolean) (defaults to: false)

    Enable strict validation

Returns:

  • (Array<String>)

    Array of error messages (empty if valid)



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

Parameters:

  • path_or_manifest (String, Manifest)

    Path to file or Manifest object

  • strict (Boolean) (defaults to: false)

    Enable strict validation

Returns:

Raises:



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