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.
-
#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.
-
#timeout(seconds) ⇒ Object
Set timeout 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.
Constructor Details
#initialize ⇒ AllAgentsBuilder
Returns a new instance of AllAgentsBuilder.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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 @timeout = nil @parameters = nil @headers = nil @coding_agent = nil @disable_default_tools = 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
55 56 57 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 55 def api_version(version) @api_version = version end |
#base_url(url) ⇒ Object
Set base URL for all agents
50 51 52 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 50 def base_url(url) @base_url = url end |
#coding_agent(enabled) ⇒ Object
Set coding_agent flag for all agents
75 76 77 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 75 def coding_agent(enabled) @coding_agent = enabled end |
#disable_default_tools(value) ⇒ Object
Disable default tools for all agents
84 85 86 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 84 def disable_default_tools(value) @disable_default_tools = value end |
#headers(header_hash) ⇒ Object
Set headers for all agents
70 71 72 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 70 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)
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 99 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
40 41 42 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 40 def model(model_name) @model = model_name end |
#parameters(params) ⇒ Object
Set parameters for all agents
65 66 67 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 65 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)
132 133 134 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 132 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.
143 144 145 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 143 def (hash) @permissions_config = hash || {} end |
#provider(provider_name) ⇒ Object
Set provider for all agents
45 46 47 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 45 def provider(provider_name) @provider = provider_name end |
#timeout(seconds) ⇒ Object
Set timeout for all agents
60 61 62 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 60 def timeout(seconds) @timeout = seconds end |
#to_h ⇒ Hash
Convert to hash for merging with agent configs
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 150 def to_h { model: @model, provider: @provider, base_url: @base_url, api_version: @api_version, timeout: @timeout, parameters: @parameters, headers: @headers, coding_agent: @coding_agent, disable_default_tools: @disable_default_tools, tools: @tools_list, permissions: @permissions_config, }.compact end |
#tools(*tool_names) ⇒ Object
Add tools that all agents will have
89 90 91 |
# File 'lib/swarm_sdk/swarm/all_agents_builder.rb', line 89 def tools(*tool_names) @tools_list.concat(tool_names) end |