Class: SwarmSDK::Swarm::AllAgentsBuilder
- Inherits:
-
Object
- Object
- SwarmSDK::Swarm::AllAgentsBuilder
- Defined in:
- lib/swarm_sdk/swarm/all_agents_builder.rb
Overview
AllAgentsBuilder for configuring settings that apply to all agents
Settings configured here are applied to ALL agents, but can be overridden at the agent level. This is useful for shared configuration like:
- Common provider/base_url (all agents use same proxy)
- Shared timeout settings
- Global permissions
Instance Attribute Summary collapse
-
#hooks ⇒ Object
readonly
Returns the value of attribute hooks.
-
#permissions_config ⇒ Object
readonly
Returns the value of attribute permissions_config.
-
#tools_list ⇒ Object
readonly
Returns the value of attribute tools_list.
Instance Method Summary collapse
-
#api_version(version) ⇒ Object
Set API version for all agents.
-
#base_url(url) ⇒ Object
Set base URL for all agents.
-
#coding_agent(enabled) ⇒ Object
Set coding_agent flag for all agents.
-
#disable_default_tools(value) ⇒ Object
Disable default tools for all agents.
-
#disable_environment_info(enabled) ⇒ Object
Disable environment info for all agents.
-
#headers(header_hash) ⇒ Object
Set headers for all agents.
-
#hook(event, matcher: nil, command: nil, timeout: nil, &block) ⇒ Object
Add hook for all agents (agent-level events only).
-
#initialize ⇒ AllAgentsBuilder
constructor
A new instance of AllAgentsBuilder.
-
#model(model_name) ⇒ Object
Set model for all agents.
-
#parameters(params) ⇒ Object
Set parameters for all agents.
-
#permissions(&block) ⇒ Object
Configure permissions for all agents.
-
#permissions_hash=(hash) ⇒ void
Set permissions directly from hash (for YAML translation).
-
#provider(provider_name) ⇒ Object
Set provider for all agents.
-
#request_timeout(seconds) ⇒ Object
Set request timeout for all agents.
-
#streaming(value) ⇒ Object
Enable or disable streaming for all agents.
-
#thinking(effort: nil, budget: nil) ⇒ Object
Configure extended thinking for all agents.
-
#to_h ⇒ Hash
Convert to hash for merging with agent configs.
-
#tools(*tool_names) ⇒ Object
Add tools that all agents will have.
-
#turn_timeout(seconds) ⇒ Object
Set turn timeout for all agents.
Constructor Details
#initialize ⇒ AllAgentsBuilder
Returns a new instance of AllAgentsBuilder.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 24 def initialize @tools_list = [] @hooks = [] @permissions_config = {} @model = nil @provider = nil @base_url = nil @api_version = nil @request_timeout = nil @turn_timeout = nil @parameters = nil @headers = nil @coding_agent = nil @disable_default_tools = nil @streaming = nil @thinking = nil @disable_environment_info = nil end |
Instance Attribute Details
#hooks ⇒ Object (readonly)
Returns the value of attribute hooks.
22 23 24 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 22 def hooks @hooks end |
#permissions_config ⇒ Object (readonly)
Returns the value of attribute permissions_config.
22 23 24 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 22 def @permissions_config end |
#tools_list ⇒ Object (readonly)
Returns the value of attribute tools_list.
22 23 24 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 22 def tools_list @tools_list end |
Instance Method Details
#api_version(version) ⇒ Object
Set API version for all agents
59 60 61 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 59 def api_version(version) @api_version = version end |
#base_url(url) ⇒ Object
Set base URL for all agents
54 55 56 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 54 def base_url(url) @base_url = url end |
#coding_agent(enabled) ⇒ Object
Set coding_agent flag for all agents
84 85 86 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 84 def coding_agent(enabled) @coding_agent = enabled end |
#disable_default_tools(value) ⇒ Object
Disable default tools for all agents
93 94 95 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 93 def disable_default_tools(value) @disable_default_tools = value end |
#disable_environment_info(enabled) ⇒ Object
Disable environment info for all agents
107 108 109 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 107 def disable_environment_info(enabled) @disable_environment_info = enabled end |
#headers(header_hash) ⇒ Object
Set headers for all agents
79 80 81 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 79 def headers(header_hash) @headers = header_hash end |
#hook(event, matcher: nil, command: nil, timeout: nil, &block) ⇒ Object
Add hook for all agents (agent-level events only)
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 132 def hook(event, matcher: nil, command: nil, timeout: nil, &block) # Validate agent-level events agent_events = [ :pre_tool_use, :post_tool_use, :user_prompt, :agent_step, :agent_stop, :first_message, :pre_delegation, :post_delegation, :context_warning, ] unless agent_events.include?(event) raise ArgumentError, "Invalid all_agents hook: #{event}. Swarm-level events (:swarm_start, :swarm_stop) cannot be used in all_agents block." end @hooks << { event: event, matcher: matcher, command: command, timeout: timeout, block: block } end |
#model(model_name) ⇒ Object
Set model for all agents
44 45 46 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 44 def model(model_name) @model = model_name end |
#parameters(params) ⇒ Object
Set parameters for all agents
74 75 76 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 74 def parameters(params) @parameters = params end |
#permissions(&block) ⇒ Object
Configure permissions for all agents
Supports two forms:
- Block form (DSL): permissions do ... end
- Direct hash (internal/YAML): set_permissions_hash(hash)
165 166 167 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 165 def (&block) @permissions_config = PermissionsBuilder.build(&block) end |
#permissions_hash=(hash) ⇒ void
This method returns an undefined value.
Set permissions directly from hash (for YAML translation)
This is intentionally separate from permissions() to keep the DSL clean. Called by Configuration when translating YAML permissions.
176 177 178 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 176 def (hash) @permissions_config = hash || {} end |
#provider(provider_name) ⇒ Object
Set provider for all agents
49 50 51 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 49 def provider(provider_name) @provider = provider_name end |
#request_timeout(seconds) ⇒ Object
Set request timeout for all agents
64 65 66 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 64 def request_timeout(seconds) @request_timeout = seconds end |
#streaming(value) ⇒ Object
Enable or disable streaming for all agents
100 101 102 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 100 def streaming(value) @streaming = value end |
#thinking(effort: nil, budget: nil) ⇒ Object
Configure extended thinking for all agents
115 116 117 118 119 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 115 def thinking(effort: nil, budget: nil) raise ArgumentError, "thinking requires :effort or :budget" if effort.nil? && budget.nil? @thinking = { effort: effort, budget: budget }.compact end |
#to_h ⇒ Hash
Convert to hash for merging with agent configs
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 183 def to_h { model: @model, provider: @provider, base_url: @base_url, api_version: @api_version, request_timeout: @request_timeout, turn_timeout: @turn_timeout, parameters: @parameters, headers: @headers, coding_agent: @coding_agent, disable_default_tools: @disable_default_tools, streaming: @streaming, thinking: @thinking, disable_environment_info: @disable_environment_info, tools: @tools_list, permissions: @permissions_config, }.compact end |
#tools(*tool_names) ⇒ Object
Add tools that all agents will have
122 123 124 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 122 def tools(*tool_names) @tools_list.concat(tool_names) end |
#turn_timeout(seconds) ⇒ Object
Set turn timeout for all agents
69 70 71 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 69 def turn_timeout(seconds) @turn_timeout = seconds end |