Class: AgentHarness::Configuration
- Inherits:
-
Object
- Object
- AgentHarness::Configuration
- Defined in:
- lib/agent_harness/configuration.rb
Overview
Configuration for AgentHarness
Supports configuration via Ruby DSL, YAML files, and environment variables. Configuration sources are merged with priority: Ruby DSL > YAML > Environment.
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
readonly
Returns the value of attribute callbacks.
-
#command_executor ⇒ CommandExecutor
Get or lazily initialize the command executor.
-
#config_file_path ⇒ Object
Returns the value of attribute config_file_path.
-
#custom_provider_classes ⇒ Object
readonly
Returns the value of attribute custom_provider_classes.
-
#default_provider ⇒ Object
Returns the value of attribute default_provider.
-
#default_timeout ⇒ Object
Returns the value of attribute default_timeout.
-
#fallback_providers ⇒ Object
Returns the value of attribute fallback_providers.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#orchestration_config ⇒ Object
readonly
Returns the value of attribute orchestration_config.
-
#providers ⇒ Object
readonly
Returns the value of attribute providers.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#on_circuit_close {|Hash| ... } ⇒ void
Register callback for circuit close events.
-
#on_circuit_open {|Hash| ... } ⇒ void
Register callback for circuit open events.
-
#on_provider_switch {|Hash| ... } ⇒ void
Register callback for provider switch events.
-
#on_tokens_used {|TokenEvent| ... } ⇒ void
Register callback for token usage events.
-
#orchestration {|OrchestrationConfig| ... } ⇒ OrchestrationConfig
Configure orchestration settings.
-
#provider(name) {|ProviderConfig| ... } ⇒ ProviderConfig
Configure a provider.
-
#register_provider(name, klass) ⇒ void
Register a custom provider class.
-
#valid? ⇒ Boolean
Check if configuration is valid.
-
#validate! ⇒ void
Validate the configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/agent_harness/configuration.rb', line 27 def initialize @logger = nil # Will use null logger if not set @log_level = :info @default_provider = :cursor @fallback_providers = [] @command_executor = nil # Lazy-initialized @config_file_path = nil @default_timeout = 300 @providers = {} @orchestration_config = OrchestrationConfig.new @callbacks = CallbackRegistry.new @custom_provider_classes = {} end |
Instance Attribute Details
#callbacks ⇒ Object (readonly)
Returns the value of attribute callbacks.
25 26 27 |
# File 'lib/agent_harness/configuration.rb', line 25 def callbacks @callbacks end |
#command_executor ⇒ CommandExecutor
Get or lazily initialize the command executor
44 45 46 |
# File 'lib/agent_harness/configuration.rb', line 44 def command_executor @command_executor ||= CommandExecutor.new(logger: @logger) end |
#config_file_path ⇒ Object
Returns the value of attribute config_file_path.
22 23 24 |
# File 'lib/agent_harness/configuration.rb', line 22 def config_file_path @config_file_path end |
#custom_provider_classes ⇒ Object (readonly)
Returns the value of attribute custom_provider_classes.
25 26 27 |
# File 'lib/agent_harness/configuration.rb', line 25 def custom_provider_classes @custom_provider_classes end |
#default_provider ⇒ Object
Returns the value of attribute default_provider.
21 22 23 |
# File 'lib/agent_harness/configuration.rb', line 21 def default_provider @default_provider end |
#default_timeout ⇒ Object
Returns the value of attribute default_timeout.
22 23 24 |
# File 'lib/agent_harness/configuration.rb', line 22 def default_timeout @default_timeout end |
#fallback_providers ⇒ Object
Returns the value of attribute fallback_providers.
21 22 23 |
# File 'lib/agent_harness/configuration.rb', line 21 def fallback_providers @fallback_providers end |
#log_level ⇒ Object
Returns the value of attribute log_level.
21 22 23 |
# File 'lib/agent_harness/configuration.rb', line 21 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
21 22 23 |
# File 'lib/agent_harness/configuration.rb', line 21 def logger @logger end |
#orchestration_config ⇒ Object (readonly)
Returns the value of attribute orchestration_config.
25 26 27 |
# File 'lib/agent_harness/configuration.rb', line 25 def orchestration_config @orchestration_config end |
#providers ⇒ Object (readonly)
Returns the value of attribute providers.
25 26 27 |
# File 'lib/agent_harness/configuration.rb', line 25 def providers @providers end |
Instance Method Details
#on_circuit_close {|Hash| ... } ⇒ void
This method returns an undefined value.
Register callback for circuit close events
105 106 107 |
# File 'lib/agent_harness/configuration.rb', line 105 def on_circuit_close(&block) @callbacks.register(:circuit_close, block) end |
#on_circuit_open {|Hash| ... } ⇒ void
This method returns an undefined value.
Register callback for circuit open events
97 98 99 |
# File 'lib/agent_harness/configuration.rb', line 97 def on_circuit_open(&block) @callbacks.register(:circuit_open, block) end |
#on_provider_switch {|Hash| ... } ⇒ void
This method returns an undefined value.
Register callback for provider switch events
89 90 91 |
# File 'lib/agent_harness/configuration.rb', line 89 def on_provider_switch(&block) @callbacks.register(:provider_switch, block) end |
#on_tokens_used {|TokenEvent| ... } ⇒ void
This method returns an undefined value.
Register callback for token usage events
81 82 83 |
# File 'lib/agent_harness/configuration.rb', line 81 def on_tokens_used(&block) @callbacks.register(:tokens_used, block) end |
#orchestration {|OrchestrationConfig| ... } ⇒ OrchestrationConfig
Configure orchestration settings
52 53 54 55 |
# File 'lib/agent_harness/configuration.rb', line 52 def orchestration(&block) yield(@orchestration_config) if block_given? @orchestration_config end |
#provider(name) {|ProviderConfig| ... } ⇒ ProviderConfig
Configure a provider
62 63 64 65 66 |
# File 'lib/agent_harness/configuration.rb', line 62 def provider(name, &block) config = ProviderConfig.new(name) yield(config) if block_given? @providers[name.to_sym] = config end |
#register_provider(name, klass) ⇒ void
This method returns an undefined value.
Register a custom provider class
73 74 75 |
# File 'lib/agent_harness/configuration.rb', line 73 def register_provider(name, klass) @custom_provider_classes[name.to_sym] = klass end |
#valid? ⇒ Boolean
Check if configuration is valid
125 126 127 128 129 130 |
# File 'lib/agent_harness/configuration.rb', line 125 def valid? validate! true rescue ConfigurationError false end |
#validate! ⇒ void
This method returns an undefined value.
Validate the configuration
113 114 115 116 117 118 119 120 |
# File 'lib/agent_harness/configuration.rb', line 113 def validate! errors = [] errors << "No providers configured" if @providers.empty? errors << "Default provider '#{@default_provider}' not configured" unless @providers[@default_provider] raise ConfigurationError, errors.join(", ") unless errors.empty? end |