Class: SolidAgent::AgentManifest::AgentBuilder
- Inherits:
-
Object
- Object
- SolidAgent::AgentManifest::AgentBuilder
- Defined in:
- lib/solid_agent/agent_manifest/agent_builder.rb
Overview
AgentBuilder generates ActiveAgent classes from Manifest definitions.
Creates anonymous or named classes with the appropriate concerns included, tools defined, and system instructions configured.
Class Method Summary collapse
-
.build(manifest, base_class: nil, class_name: nil, namespace: nil) ⇒ Class
Build an agent class from a manifest.
-
.build_from_file(path, **options) ⇒ Class
Build from a file path.
-
.build_instance(manifest, params: {}, **options) ⇒ Object
Build and instantiate an agent from a manifest.
Class Method Details
.build(manifest, base_class: nil, class_name: nil, namespace: nil) ⇒ Class
Build an agent class from a manifest
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/solid_agent/agent_manifest/agent_builder.rb', line 32 def build(manifest, base_class: nil, class_name: nil, namespace: nil) # Determine base class parent_class = determine_base_class(manifest, base_class) # Create the class klass = Class.new(parent_class) # Configure the agent configure_model(klass, manifest) configure_concerns(klass, manifest) configure_tools(klass, manifest) configure_instructions(klass, manifest) (klass, manifest) # Register as constant if requested if class_name || manifest_class_name(manifest) register_constant(klass, class_name || manifest_class_name(manifest), namespace) end klass end |
.build_from_file(path, **options) ⇒ Class
Build from a file path
69 70 71 72 |
# File 'lib/solid_agent/agent_manifest/agent_builder.rb', line 69 def build_from_file(path, **) manifest = ParserRegistry.parse(path) build(manifest, **) end |
.build_instance(manifest, params: {}, **options) ⇒ Object
Build and instantiate an agent from a manifest
59 60 61 62 |
# File 'lib/solid_agent/agent_manifest/agent_builder.rb', line 59 def build_instance(manifest, params: {}, **) klass = build(manifest, **) klass.new(params) end |