ruby_llm-agents 3.11.0 → 3.12.0

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.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/ruby_llm/agents/agents_controller.rb +74 -0
  3. data/app/controllers/ruby_llm/agents/analytics_controller.rb +304 -0
  4. data/app/controllers/ruby_llm/agents/tenants_controller.rb +74 -2
  5. data/app/models/ruby_llm/agents/agent_override.rb +47 -0
  6. data/app/models/ruby_llm/agents/execution/analytics.rb +37 -16
  7. data/app/services/ruby_llm/agents/agent_registry.rb +8 -1
  8. data/app/views/layouts/ruby_llm/agents/application.html.erb +4 -2
  9. data/app/views/ruby_llm/agents/agents/_config_agent.html.erb +89 -4
  10. data/app/views/ruby_llm/agents/agents/show.html.erb +14 -0
  11. data/app/views/ruby_llm/agents/analytics/index.html.erb +398 -0
  12. data/app/views/ruby_llm/agents/tenants/index.html.erb +3 -2
  13. data/app/views/ruby_llm/agents/tenants/show.html.erb +225 -0
  14. data/config/routes.rb +12 -4
  15. data/lib/generators/ruby_llm_agents/templates/create_overrides_migration.rb.tt +28 -0
  16. data/lib/generators/ruby_llm_agents/templates/skills/AGENTS.md.tt +1 -1
  17. data/lib/generators/ruby_llm_agents/templates/skills/TOOLS.md.tt +1 -1
  18. data/lib/generators/ruby_llm_agents/upgrade_generator.rb +14 -0
  19. data/lib/ruby_llm/agents/base_agent.rb +90 -133
  20. data/lib/ruby_llm/agents/core/base.rb +9 -0
  21. data/lib/ruby_llm/agents/core/configuration.rb +5 -1
  22. data/lib/ruby_llm/agents/core/version.rb +1 -1
  23. data/lib/ruby_llm/agents/dsl/base.rb +131 -4
  24. data/lib/ruby_llm/agents/dsl/knowledge.rb +157 -0
  25. data/lib/ruby_llm/agents/dsl.rb +1 -1
  26. data/lib/ruby_llm/agents/pipeline/middleware/budget.rb +32 -20
  27. data/lib/ruby_llm/agents/pipeline/middleware/instrumentation.rb +22 -1
  28. data/lib/ruby_llm/agents/pipeline/middleware/reliability.rb +1 -1
  29. data/lib/ruby_llm/agents/stream_event.rb +2 -10
  30. data/lib/ruby_llm/agents/tool.rb +1 -1
  31. data/lib/ruby_llm/agents.rb +0 -3
  32. metadata +6 -3
  33. data/lib/ruby_llm/agents/agent_tool.rb +0 -143
  34. data/lib/ruby_llm/agents/dsl/agents.rb +0 -141
@@ -1,141 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyLLM
4
- module Agents
5
- module DSL
6
- # DSL module for declaring sub-agents on an agent class.
7
- #
8
- # Provides two forms — simple list for common cases, block for
9
- # per-agent configuration:
10
- #
11
- # @example Simple form
12
- # agents [ModelsAgent, ViewsAgent], forward: [:workspace_path]
13
- #
14
- # @example Block form
15
- # agents do
16
- # use ModelsAgent, timeout: 180, description: "Build models"
17
- # use ViewsAgent
18
- # forward :workspace_path, :project_id
19
- # parallel true
20
- # end
21
- #
22
- module Agents
23
- # Declares sub-agents for this agent class.
24
- #
25
- # @param list [Array<Class>, nil] Agent classes (simple form)
26
- # @param options [Hash] Global options (simple form)
27
- # @yield Configuration block (block form)
28
- # @return [Array<Hash>] Agent entries
29
- def agents(list = nil, **options, &block)
30
- if block
31
- config = AgentsConfig.new
32
- config.instance_eval(&block)
33
- @agents_config = config
34
- elsif list
35
- config = AgentsConfig.new
36
- Array(list).each { |a| config.use(a) }
37
- options.each { |k, v| config.send(k, *Array(v)) }
38
- @agents_config = config
39
- end
40
- @agents_config&.agent_entries || []
41
- end
42
-
43
- # Returns the agents configuration object.
44
- #
45
- # @return [AgentsConfig] Configuration (empty if no agents declared)
46
- def agents_config
47
- @agents_config ||
48
- (superclass.respond_to?(:agents_config) ? superclass.agents_config : nil) ||
49
- AgentsConfig.new
50
- end
51
- end
52
- end
53
-
54
- # Configuration object for the `agents` DSL.
55
- #
56
- # Holds the list of agent entries and global options like
57
- # `parallel`, `forward`, `max_depth`, and `instructions`.
58
- #
59
- class AgentsConfig
60
- attr_reader :agent_entries
61
-
62
- def initialize
63
- @agent_entries = []
64
- @options = {
65
- parallel: true,
66
- timeout: nil,
67
- max_depth: 5,
68
- forward: [],
69
- instructions: nil
70
- }
71
- end
72
-
73
- # Registers an agent class with optional per-agent overrides.
74
- #
75
- # @param agent_class [Class] A BaseAgent subclass
76
- # @param timeout [Integer, nil] Per-agent timeout override
77
- # @param description [String, nil] Per-agent description override
78
- def use(agent_class, timeout: nil, description: nil)
79
- @agent_entries << {
80
- agent_class: agent_class,
81
- timeout: timeout,
82
- description: description
83
- }
84
- end
85
-
86
- # @!group Global Options
87
-
88
- def parallel(value = true)
89
- @options[:parallel] = value
90
- end
91
-
92
- def timeout(seconds)
93
- @options[:timeout] = seconds
94
- end
95
-
96
- def max_depth(depth)
97
- @options[:max_depth] = depth
98
- end
99
-
100
- def instructions(text)
101
- @options[:instructions] = text
102
- end
103
-
104
- def forward(*params)
105
- @options[:forward] = params.flatten
106
- end
107
-
108
- # @!endgroup
109
-
110
- # @!group Query Methods
111
-
112
- def parallel?
113
- @options[:parallel]
114
- end
115
-
116
- def timeout_for(agent_class)
117
- entry = @agent_entries.find { |e| e[:agent_class] == agent_class }
118
- entry&.dig(:timeout) || @options[:timeout]
119
- end
120
-
121
- def forwarded_params
122
- @options[:forward]
123
- end
124
-
125
- def max_depth_value
126
- @options[:max_depth]
127
- end
128
-
129
- def instructions_text
130
- @options[:instructions]
131
- end
132
-
133
- def description_for(agent_class)
134
- entry = @agent_entries.find { |e| e[:agent_class] == agent_class }
135
- entry&.dig(:description)
136
- end
137
-
138
- # @!endgroup
139
- end
140
- end
141
- end