ruby_llm-agents 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/ruby_llm/agents/application_controller.rb +20 -3
- data/lib/generators/ruby_llm_agents/templates/initializer.rb.tt +6 -1
- data/lib/ruby_llm/agents/configuration.rb +5 -1
- data/lib/ruby_llm/agents/engine.rb +38 -0
- data/lib/ruby_llm/agents/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 03e22b362e20b0322d49726f9bb22f202d4fa642691f3a3b885d5cc4e7c661cf
|
|
4
|
+
data.tar.gz: 327a34b0ef344b4a65edf23fda0360b1e2bcc5f33e43881521418686f2113565
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 83bdf11edc73064e92f98b220849e5d29ad62aa79ee853880eda80763c70e4a7aec13129f299df70db6dc3a9d08c102a12ca857ca6557b9b6a56db81430ea38a
|
|
7
|
+
data.tar.gz: 8c8f29bb00b446e44d2b15578b823812f72e533976244407549bcf4414db51a8e33676fdbb36ebab41a7f22d2d85a1a63de1d2c0c7e40d5b58ebfad128a9a634
|
|
@@ -10,10 +10,27 @@ module RubyLLM
|
|
|
10
10
|
private
|
|
11
11
|
|
|
12
12
|
def authenticate_dashboard!
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
if basic_auth_configured?
|
|
14
|
+
authenticate_with_http_basic_auth
|
|
15
|
+
else
|
|
16
|
+
auth_proc = RubyLLM::Agents.configuration.dashboard_auth
|
|
17
|
+
return if auth_proc.call(self)
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
render plain: "Unauthorized", status: :unauthorized
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def basic_auth_configured?
|
|
24
|
+
config = RubyLLM::Agents.configuration
|
|
25
|
+
config.basic_auth_username.present? && config.basic_auth_password.present?
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def authenticate_with_http_basic_auth
|
|
29
|
+
config = RubyLLM::Agents.configuration
|
|
30
|
+
authenticate_or_request_with_http_basic("RubyLLM Agents") do |username, password|
|
|
31
|
+
ActiveSupport::SecurityUtils.secure_compare(username, config.basic_auth_username) &&
|
|
32
|
+
ActiveSupport::SecurityUtils.secure_compare(password, config.basic_auth_password)
|
|
33
|
+
end
|
|
17
34
|
end
|
|
18
35
|
end
|
|
19
36
|
end
|
|
@@ -27,8 +27,13 @@ RubyLLM::Agents.configure do |config|
|
|
|
27
27
|
# config.anomaly_cost_threshold = 5.00 # dollars
|
|
28
28
|
# config.anomaly_duration_threshold = 10_000 # milliseconds
|
|
29
29
|
|
|
30
|
-
#
|
|
30
|
+
# HTTP Basic Auth (simple username/password protection)
|
|
31
|
+
# config.basic_auth_username = "admin"
|
|
32
|
+
# config.basic_auth_password = Rails.application.credentials.agents_password
|
|
33
|
+
|
|
34
|
+
# Dashboard authentication (advanced - custom logic)
|
|
31
35
|
# Return true to allow access, false to deny
|
|
36
|
+
# Note: If basic_auth_username/password are set, they take precedence
|
|
32
37
|
# config.dashboard_auth = ->(controller) { controller.current_user&.admin? }
|
|
33
38
|
|
|
34
39
|
# Parent controller for dashboard (for authentication/layout inheritance)
|
|
@@ -11,7 +11,9 @@ module RubyLLM
|
|
|
11
11
|
:anomaly_cost_threshold,
|
|
12
12
|
:anomaly_duration_threshold,
|
|
13
13
|
:dashboard_auth,
|
|
14
|
-
:dashboard_parent_controller
|
|
14
|
+
:dashboard_parent_controller,
|
|
15
|
+
:basic_auth_username,
|
|
16
|
+
:basic_auth_password
|
|
15
17
|
|
|
16
18
|
attr_writer :cache_store
|
|
17
19
|
|
|
@@ -26,6 +28,8 @@ module RubyLLM
|
|
|
26
28
|
@anomaly_duration_threshold = 10_000
|
|
27
29
|
@dashboard_auth = ->(_controller) { true }
|
|
28
30
|
@dashboard_parent_controller = "ActionController::Base"
|
|
31
|
+
@basic_auth_username = nil
|
|
32
|
+
@basic_auth_password = nil
|
|
29
33
|
end
|
|
30
34
|
|
|
31
35
|
def cache_store
|
|
@@ -11,6 +11,44 @@ module RubyLLM
|
|
|
11
11
|
require_relative "execution_logger_job"
|
|
12
12
|
require_relative "instrumentation"
|
|
13
13
|
require_relative "base"
|
|
14
|
+
|
|
15
|
+
# Dynamically set parent controller based on configuration
|
|
16
|
+
parent_class = RubyLLM::Agents.configuration.dashboard_parent_controller.constantize
|
|
17
|
+
|
|
18
|
+
# Remove existing constant if defined, then redefine with correct parent
|
|
19
|
+
RubyLLM::Agents.send(:remove_const, :ApplicationController) if RubyLLM::Agents.const_defined?(:ApplicationController, false)
|
|
20
|
+
|
|
21
|
+
RubyLLM::Agents.const_set(:ApplicationController, Class.new(parent_class) do
|
|
22
|
+
layout "rubyllm/agents/application"
|
|
23
|
+
helper RubyLLM::Agents::ApplicationHelper
|
|
24
|
+
before_action :authenticate_dashboard!
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def authenticate_dashboard!
|
|
29
|
+
if basic_auth_configured?
|
|
30
|
+
authenticate_with_http_basic_auth
|
|
31
|
+
else
|
|
32
|
+
auth_proc = RubyLLM::Agents.configuration.dashboard_auth
|
|
33
|
+
return if auth_proc.call(self)
|
|
34
|
+
|
|
35
|
+
render plain: "Unauthorized", status: :unauthorized
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def basic_auth_configured?
|
|
40
|
+
config = RubyLLM::Agents.configuration
|
|
41
|
+
config.basic_auth_username.present? && config.basic_auth_password.present?
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def authenticate_with_http_basic_auth
|
|
45
|
+
config = RubyLLM::Agents.configuration
|
|
46
|
+
authenticate_or_request_with_http_basic("RubyLLM Agents") do |username, password|
|
|
47
|
+
ActiveSupport::SecurityUtils.secure_compare(username, config.basic_auth_username) &&
|
|
48
|
+
ActiveSupport::SecurityUtils.secure_compare(password, config.basic_auth_password)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end)
|
|
14
52
|
end
|
|
15
53
|
|
|
16
54
|
# Configure generators
|