Class: RubyLLM::Agents::AgentRegistry
- Inherits:
-
Object
- Object
- RubyLLM::Agents::AgentRegistry
- Defined in:
- app/services/ruby_llm/agents/agent_registry.rb
Overview
Service for discovering and listing available agents
Combines two sources to ensure complete agent discovery:
-
File system - Classes inheriting from ApplicationAgent in app/agents/
-
Execution history - Agent types that have execution records
This ensures visibility of both current agents and deleted agents that still have execution history.
Class Method Summary collapse
-
.all ⇒ Array<String>
Returns all unique agent type names.
-
.all_with_details ⇒ Array<Hash>
Returns detailed info about all agents.
-
.config_for(agent_class) ⇒ Hash
Extracts full configuration for an agent class.
-
.exists?(agent_type) ⇒ Boolean
Checks if an agent class is currently defined.
-
.find(agent_type) ⇒ Class?
Finds an agent class by type name.
Class Method Details
.all ⇒ Array<String>
Returns all unique agent type names
28 29 30 |
# File 'app/services/ruby_llm/agents/agent_registry.rb', line 28 def all (file_system_agents + execution_agents).uniq.sort end |
.all_with_details ⇒ Array<Hash>
Returns detailed info about all agents
51 52 53 54 55 |
# File 'app/services/ruby_llm/agents/agent_registry.rb', line 51 def all_with_details all.map do |agent_type| build_agent_info(agent_type) end end |
.config_for(agent_class) ⇒ Hash
Extracts full configuration for an agent class
Combines base config with type-specific config for display.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/services/ruby_llm/agents/agent_registry.rb', line 63 def config_for(agent_class) return {} unless agent_class base = { model: safe_call(agent_class, :model), version: safe_call(agent_class, :version), description: safe_call(agent_class, :description) } type = detect_agent_type(agent_class) config = base.merge(type_config_for(agent_class, type)) # Include dashboard override metadata config[:overridable_fields] = safe_call(agent_class, :overridable_fields) || [] config[:active_overrides] = safe_call(agent_class, :active_overrides) || {} config[:has_overrides] = config[:active_overrides].any? config end |
.exists?(agent_type) ⇒ Boolean
Checks if an agent class is currently defined
44 45 46 |
# File 'app/services/ruby_llm/agents/agent_registry.rb', line 44 def exists?(agent_type) find(agent_type).present? end |
.find(agent_type) ⇒ Class?
Finds an agent class by type name
36 37 38 |
# File 'app/services/ruby_llm/agents/agent_registry.rb', line 36 def find(agent_type) agent_type.safe_constantize end |