Class: Ask::Ruby::Harness::Configuration
- Inherits:
-
Object
- Object
- Ask::Ruby::Harness::Configuration
- Defined in:
- lib/ask/ruby/harness/configuration.rb
Constant Summary collapse
- DATABASE_CONFIG_KEYS =
Keys accepted when building a standalone connection from config/database.yml (unknown keys would fail AR's config validation).
%w[adapter database host port username password url encoding pool].freeze
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 environment.
-
#effective_denied_commands ⇒ Array<Regexp>?
Resolved denied commands for the current environment.
-
#effective_mode ⇒ Symbol?
Resolved access mode for the current environment.
-
#environment(name) {|env| ... } ⇒ Object
Configure permissions for a specific environment.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ask/ruby/harness/configuration.rb', line 19 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.
11 12 13 |
# File 'lib/ask/ruby/harness/configuration.rb', line 11 def allowed_commands @allowed_commands end |
#current_user ⇒ Object
Returns the value of attribute current_user.
11 12 13 |
# File 'lib/ask/ruby/harness/configuration.rb', line 11 def current_user @current_user end |
#default_model ⇒ Object
Returns the value of attribute default_model.
11 12 13 |
# File 'lib/ask/ruby/harness/configuration.rb', line 11 def default_model @default_model end |
#denied_commands ⇒ Object
Returns the value of attribute denied_commands.
11 12 13 |
# File 'lib/ask/ruby/harness/configuration.rb', line 11 def denied_commands @denied_commands end |
#environments ⇒ Hash{Symbol => EnvironmentPermissions} (readonly)
Returns per-environment permission rules.
17 18 19 |
# File 'lib/ask/ruby/harness/configuration.rb', line 17 def environments @environments end |
#max_session_age ⇒ Object
Returns the value of attribute max_session_age.
11 12 13 |
# File 'lib/ask/ruby/harness/configuration.rb', line 11 def max_session_age @max_session_age end |
#max_sessions ⇒ Object
Returns the value of attribute max_sessions.
11 12 13 |
# File 'lib/ask/ruby/harness/configuration.rb', line 11 def max_sessions @max_sessions end |
#max_turns ⇒ Object
Returns the value of attribute max_turns.
11 12 13 |
# File 'lib/ask/ruby/harness/configuration.rb', line 11 def max_turns @max_turns end |
#persistence_adapter ⇒ Object
Returns the value of attribute persistence_adapter.
11 12 13 |
# File 'lib/ask/ruby/harness/configuration.rb', line 11 def persistence_adapter @persistence_adapter end |
#system_prompt ⇒ Object
Returns the value of attribute system_prompt.
11 12 13 |
# File 'lib/ask/ruby/harness/configuration.rb', line 11 def system_prompt @system_prompt end |
#tool_concurrency ⇒ Object
Returns the value of attribute tool_concurrency.
11 12 13 |
# File 'lib/ask/ruby/harness/configuration.rb', line 11 def tool_concurrency @tool_concurrency end |
#tools ⇒ Object
Returns the value of attribute tools.
11 12 13 |
# File 'lib/ask/ruby/harness/configuration.rb', line 11 def tools @tools end |
Instance Method Details
#effective_allowed_commands ⇒ Array<Regexp>?
Resolved allowed commands for the current environment.
Falls back to the global allowed_commands if no per-env config.
53 54 55 56 |
# File 'lib/ask/ruby/harness/configuration.rb', line 53 def effective_allowed_commands env = @environments[Ask::Ruby::Harness.env.to_sym] env&.allowed_commands || @allowed_commands end |
#effective_denied_commands ⇒ Array<Regexp>?
Resolved denied commands for the current environment.
Falls back to the global denied_commands if no per-env config.
62 63 64 65 |
# File 'lib/ask/ruby/harness/configuration.rb', line 62 def effective_denied_commands env = @environments[Ask::Ruby::Harness.env.to_sym] env&.denied_commands || @denied_commands end |
#effective_mode ⇒ Symbol?
Resolved access mode for the current environment.
70 71 72 73 |
# File 'lib/ask/ruby/harness/configuration.rb', line 70 def effective_mode env = @environments[Ask::Ruby::Harness.env.to_sym] env&.mode || nil end |
#environment(name) {|env| ... } ⇒ Object
Configure permissions for a specific environment.
config.environment :production do |env|
env.mode = :read_only
env.allowed_commands = [/^rails routes/]
env.denied_commands = [/rm/, /dropdb/]
end
43 44 45 46 47 |
# File 'lib/ask/ruby/harness/configuration.rb', line 43 def environment(name) env = EnvironmentPermissions.new yield env @environments[name.to_sym] = env end |