Class: Chocomint::Config
- Inherits:
-
Object
- Object
- Chocomint::Config
- Defined in:
- lib/chocomint/config.rb
Overview
config/config.yml を読み込み、環境変数オーバーライドを適用する。
Constant Summary collapse
- DEFAULT_PATH =
File.("../../config/config.yml", __dir__)
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
-
#allow_all_commands? ⇒ Boolean
true なら run_command で allowed_commands の whitelist チェックを行わず任意コマンドを実行する。.
- #allowed_commands ⇒ Object
- #allowed_dirs ⇒ Object
-
#console_ws_port ⇒ Object
AI エディタのコンソール (WebSocket) 用ポート。既定は HTTP ポート+1。.
-
#console_ws_token ⇒ Object
コンソール接続に要求する共有トークン。未設定なら nil (ローカル限定運用向け)。.
- #execution ⇒ Object
-
#initialize(data) ⇒ Config
constructor
A new instance of Config.
- #llm ⇒ Object
- #logging ⇒ Object
- #max_file_bytes ⇒ Object
- #max_output_bytes ⇒ Object
- #max_retry ⇒ Object
-
#max_steps ⇒ Object
マルチステップ実行のステップ数上限。未設定なら max_retry を流用する (暴走防止)。.
- #security ⇒ Object
- #server ⇒ Object
- #server_host ⇒ Object
- #server_port ⇒ Object
- #sqlite_path ⇒ Object
- #timeout_sec ⇒ Object
- #verifier ⇒ Object
- #verifier_enabled? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ Config
Returns a new instance of Config.
17 18 19 20 |
# File 'lib/chocomint/config.rb', line 17 def initialize(data) @data = deep_stringify(data) apply_env_overrides! end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
10 11 12 |
# File 'lib/chocomint/config.rb', line 10 def data @data end |
Class Method Details
.load(path = DEFAULT_PATH) ⇒ Object
12 13 14 15 |
# File 'lib/chocomint/config.rb', line 12 def self.load(path = DEFAULT_PATH) raw = File.exist?(path) ? YAML.safe_load(File.read(path)) : {} new(raw || {}) end |
Instance Method Details
#allow_all_commands? ⇒ Boolean
true なら run_command で allowed_commands の whitelist チェックを行わず任意コマンドを実行する。
46 |
# File 'lib/chocomint/config.rb', line 46 def allow_all_commands? = security.fetch("allow_all_commands", false) |
#allowed_commands ⇒ Object
44 45 |
# File 'lib/chocomint/config.rb', line 44 def allowed_commands = security.fetch("allowed_commands", []) # true なら run_command で allowed_commands の whitelist チェックを行わず任意コマンドを実行する。 |
#allowed_dirs ⇒ Object
42 |
# File 'lib/chocomint/config.rb', line 42 def allowed_dirs = security.fetch("allowed_dirs", ["."]) |
#console_ws_port ⇒ Object
AI エディタのコンソール (WebSocket) 用ポート。既定は HTTP ポート+1。
32 33 |
# File 'lib/chocomint/config.rb', line 32 def console_ws_port = ENV.fetch("CHOCOMINT_WS_PORT", server.fetch("ws_port", server_port + 1)).to_i # コンソール接続に要求する共有トークン。未設定なら nil (ローカル限定運用向け)。 |
#console_ws_token ⇒ Object
コンソール接続に要求する共有トークン。未設定なら nil (ローカル限定運用向け)。
34 |
# File 'lib/chocomint/config.rb', line 34 def console_ws_token = ENV.fetch("CHOCOMINT_WS_TOKEN", server.fetch("ws_token", nil)) |
#execution ⇒ Object
24 |
# File 'lib/chocomint/config.rb', line 24 def execution = @data.fetch("execution", {}) |
#llm ⇒ Object
22 |
# File 'lib/chocomint/config.rb', line 22 def llm = @data.fetch("llm", {}) |
#logging ⇒ Object
26 |
# File 'lib/chocomint/config.rb', line 26 def logging = @data.fetch("logging", {}) |
#max_file_bytes ⇒ Object
43 |
# File 'lib/chocomint/config.rb', line 43 def max_file_bytes = security.fetch("max_file_bytes", 10_485_760) |
#max_output_bytes ⇒ Object
40 |
# File 'lib/chocomint/config.rb', line 40 def max_output_bytes = execution.fetch("max_output_bytes", 1_048_576) |
#max_retry ⇒ Object
36 37 |
# File 'lib/chocomint/config.rb', line 36 def max_retry = execution.fetch("max_retry", 10) # マルチステップ実行のステップ数上限。未設定なら max_retry を流用する (暴走防止)。 |
#max_steps ⇒ Object
マルチステップ実行のステップ数上限。未設定なら max_retry を流用する (暴走防止)。
38 |
# File 'lib/chocomint/config.rb', line 38 def max_steps = execution.fetch("max_steps", max_retry) |
#security ⇒ Object
25 |
# File 'lib/chocomint/config.rb', line 25 def security = @data.fetch("security", {}) |
#server ⇒ Object
27 |
# File 'lib/chocomint/config.rb', line 27 def server = @data.fetch("server", {}) |
#server_host ⇒ Object
29 |
# File 'lib/chocomint/config.rb', line 29 def server_host = ENV.fetch("CHOCOMINT_HOST", server.fetch("host", "127.0.0.1")) |
#server_port ⇒ Object
30 31 |
# File 'lib/chocomint/config.rb', line 30 def server_port = ENV.fetch("CHOCOMINT_PORT", server.fetch("port", 9210)).to_i # AI エディタのコンソール (WebSocket) 用ポート。既定は HTTP ポート+1。 |
#sqlite_path ⇒ Object
48 |
# File 'lib/chocomint/config.rb', line 48 def sqlite_path = logging.fetch("sqlite_path", "./logs/execution.db") |
#timeout_sec ⇒ Object
39 |
# File 'lib/chocomint/config.rb', line 39 def timeout_sec = execution.fetch("timeout_sec", 30) |
#verifier ⇒ Object
23 |
# File 'lib/chocomint/config.rb', line 23 def verifier = @data.fetch("verifier", {}) |
#verifier_enabled? ⇒ Boolean
50 |
# File 'lib/chocomint/config.rb', line 50 def verifier_enabled? = verifier.fetch("enabled", false) |