Class: ConsoleAgent::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/console_agent/configuration.rb

Constant Summary collapse

PROVIDERS =
i[anthropic openai].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/console_agent/configuration.rb', line 12

def initialize
  @provider     = :anthropic
  @api_key      = nil
  @model        = nil
  @max_tokens   = 4096
  @auto_execute = false
  @temperature  = 0.2
  @timeout      = 30
  @debug        = false
  @max_tool_rounds = 100
  @storage_adapter  = nil
  @memories_enabled = true
  @session_logging  = true
  @connection_class = nil
  @admin_username   = nil
  @admin_password   = nil
end

Instance Attribute Details

#admin_passwordObject

Returns the value of attribute admin_password.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def admin_password
  @admin_password
end

#admin_usernameObject

Returns the value of attribute admin_username.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def admin_username
  @admin_username
end

#api_keyObject

Returns the value of attribute api_key.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def api_key
  @api_key
end

#auto_executeObject

Returns the value of attribute auto_execute.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def auto_execute
  @auto_execute
end

#connection_classObject

Returns the value of attribute connection_class.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def connection_class
  @connection_class
end

#debugObject

Returns the value of attribute debug.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def debug
  @debug
end

#max_tokensObject

Returns the value of attribute max_tokens.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def max_tokens
  @max_tokens
end

#max_tool_roundsObject

Returns the value of attribute max_tool_rounds.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def max_tool_rounds
  @max_tool_rounds
end

#memories_enabledObject

Returns the value of attribute memories_enabled.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def memories_enabled
  @memories_enabled
end

#modelObject

Returns the value of attribute model.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def model
  @model
end

#providerObject

Returns the value of attribute provider.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def provider
  @provider
end

#session_loggingObject

Returns the value of attribute session_logging.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def session_logging
  @session_logging
end

#storage_adapterObject

Returns the value of attribute storage_adapter.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def storage_adapter
  @storage_adapter
end

#temperatureObject

Returns the value of attribute temperature.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def temperature
  @temperature
end

#timeoutObject

Returns the value of attribute timeout.



5
6
7
# File 'lib/console_agent/configuration.rb', line 5

def timeout
  @timeout
end

Instance Method Details

#resolved_api_keyObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/console_agent/configuration.rb', line 30

def resolved_api_key
  return @api_key if @api_key && !@api_key.empty?

  case @provider
  when :anthropic
    ENV['ANTHROPIC_API_KEY']
  when :openai
    ENV['OPENAI_API_KEY']
  end
end

#resolved_modelObject



41
42
43
44
45
46
47
48
49
50
# File 'lib/console_agent/configuration.rb', line 41

def resolved_model
  return @model if @model && !@model.empty?

  case @provider
  when :anthropic
    'claude-opus-4-6'
  when :openai
    'gpt-5.3-codex'
  end
end

#validate!Object



52
53
54
55
56
57
58
59
60
61
# File 'lib/console_agent/configuration.rb', line 52

def validate!
  unless PROVIDERS.include?(@provider)
    raise ConfigurationError, "Unknown provider: #{@provider}. Valid: #{PROVIDERS.join(', ')}"
  end

  unless resolved_api_key
    env_var = @provider == :anthropic ? 'ANTHROPIC_API_KEY' : 'OPENAI_API_KEY'
    raise ConfigurationError, "No API key. Set config.api_key or #{env_var} env var."
  end
end