Class: Ask::Rails::Harness::Configuration
- Inherits:
-
Object
- Object
- Ask::Rails::Harness::Configuration
- Defined in:
- lib/ask/rails/harness/configuration.rb
Instance Attribute Summary collapse
-
#allowed_commands ⇒ Object
Returns the value of attribute allowed_commands.
-
#current_user ⇒ Object
Returns the value of attribute current_user.
-
#default_model ⇒ Object
Returns the value of attribute default_model.
-
#denied_commands ⇒ Object
Returns the value of attribute denied_commands.
-
#environments ⇒ Hash{Symbol => EnvironmentPermissions}
readonly
Per-environment permission rules.
-
#max_session_age ⇒ Object
Returns the value of attribute max_session_age.
-
#max_sessions ⇒ Object
Returns the value of attribute max_sessions.
-
#max_turns ⇒ Object
Returns the value of attribute max_turns.
-
#persistence_adapter ⇒ Object
Returns the value of attribute persistence_adapter.
-
#system_prompt ⇒ Object
Returns the value of attribute system_prompt.
-
#tool_concurrency ⇒ Object
Returns the value of attribute tool_concurrency.
-
#tools ⇒ Object
Returns the value of attribute tools.
Instance Method Summary collapse
-
#effective_allowed_commands ⇒ Array<Regexp>?
Resolved allowed commands for the current Rails environment.
-
#effective_denied_commands ⇒ Array<Regexp>?
Resolved denied commands for the current Rails environment.
-
#effective_mode ⇒ Symbol?
Resolved access mode for the current Rails environment.
-
#environment(name) {|env| ... } ⇒ Object
Configure permissions for a specific Rails environment.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ask/rails/harness/configuration.rb', line 15 def initialize @default_model = "gpt-4o" @max_turns = 25 @system_prompt = nil @tool_concurrency = 5 @persistence_adapter = nil @tools = [] @current_user = nil @allowed_commands = nil @denied_commands = nil @max_session_age = nil @max_sessions = nil @environments = {} end |
Instance Attribute Details
#allowed_commands ⇒ Object
Returns the value of attribute allowed_commands.
7 8 9 |
# File 'lib/ask/rails/harness/configuration.rb', line 7 def allowed_commands @allowed_commands end |
#current_user ⇒ Object
Returns the value of attribute current_user.
7 8 9 |
# File 'lib/ask/rails/harness/configuration.rb', line 7 def current_user @current_user end |
#default_model ⇒ Object
Returns the value of attribute default_model.
7 8 9 |
# File 'lib/ask/rails/harness/configuration.rb', line 7 def default_model @default_model end |
#denied_commands ⇒ Object
Returns the value of attribute denied_commands.
7 8 9 |
# File 'lib/ask/rails/harness/configuration.rb', line 7 def denied_commands @denied_commands end |
#environments ⇒ Hash{Symbol => EnvironmentPermissions} (readonly)
Returns per-environment permission rules.
13 14 15 |
# File 'lib/ask/rails/harness/configuration.rb', line 13 def environments @environments end |
#max_session_age ⇒ Object
Returns the value of attribute max_session_age.
7 8 9 |
# File 'lib/ask/rails/harness/configuration.rb', line 7 def max_session_age @max_session_age end |
#max_sessions ⇒ Object
Returns the value of attribute max_sessions.
7 8 9 |
# File 'lib/ask/rails/harness/configuration.rb', line 7 def max_sessions @max_sessions end |
#max_turns ⇒ Object
Returns the value of attribute max_turns.
7 8 9 |
# File 'lib/ask/rails/harness/configuration.rb', line 7 def max_turns @max_turns end |
#persistence_adapter ⇒ Object
Returns the value of attribute persistence_adapter.
7 8 9 |
# File 'lib/ask/rails/harness/configuration.rb', line 7 def persistence_adapter @persistence_adapter end |
#system_prompt ⇒ Object
Returns the value of attribute system_prompt.
7 8 9 |
# File 'lib/ask/rails/harness/configuration.rb', line 7 def system_prompt @system_prompt end |
#tool_concurrency ⇒ Object
Returns the value of attribute tool_concurrency.
7 8 9 |
# File 'lib/ask/rails/harness/configuration.rb', line 7 def tool_concurrency @tool_concurrency end |
#tools ⇒ Object
Returns the value of attribute tools.
7 8 9 |
# File 'lib/ask/rails/harness/configuration.rb', line 7 def tools @tools end |
Instance Method Details
#effective_allowed_commands ⇒ Array<Regexp>?
Resolved allowed commands for the current Rails environment.
Falls back to the global allowed_commands if no per-env config.
49 50 51 52 |
# File 'lib/ask/rails/harness/configuration.rb', line 49 def effective_allowed_commands env = @environments[::Rails.env.to_sym] env&.allowed_commands || @allowed_commands end |
#effective_denied_commands ⇒ Array<Regexp>?
Resolved denied commands for the current Rails environment.
Falls back to the global denied_commands if no per-env config.
58 59 60 61 |
# File 'lib/ask/rails/harness/configuration.rb', line 58 def effective_denied_commands env = @environments[::Rails.env.to_sym] env&.denied_commands || @denied_commands end |
#effective_mode ⇒ Symbol?
Resolved access mode for the current Rails environment.
66 67 68 69 |
# File 'lib/ask/rails/harness/configuration.rb', line 66 def effective_mode env = @environments[::Rails.env.to_sym] env&.mode || nil end |
#environment(name) {|env| ... } ⇒ Object
Configure permissions for a specific Rails environment.
config.environment :production do |env|
env.mode = :read_only
env.allowed_commands = [/^rails routes/]
env.denied_commands = [/rm/, /dropdb/]
end
39 40 41 42 43 |
# File 'lib/ask/rails/harness/configuration.rb', line 39 def environment(name) env = EnvironmentPermissions.new yield env @environments[name.to_sym] = env end |