Class: SwarmSDK::Observer::Config
- Inherits:
-
Object
- Object
- SwarmSDK::Observer::Config
- Defined in:
- lib/swarm_sdk/observer/config.rb
Overview
Configuration for an observer agent
Holds the agent name, event handlers (blocks that return prompts or nil), and execution options.
Instance Attribute Summary collapse
-
#agent_name ⇒ Object
readonly
Returns the value of attribute agent_name.
-
#event_handlers ⇒ Object
readonly
Returns the value of attribute event_handlers.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#add_handler(event_type) {|Hash| ... } ⇒ void
Add an event handler for a specific event type.
-
#initialize(agent_name) ⇒ Config
constructor
Initialize a new observer configuration.
Constructor Details
#initialize(agent_name) ⇒ Config
Initialize a new observer configuration
20 21 22 23 24 25 26 27 28 |
# File 'lib/swarm_sdk/observer/config.rb', line 20 def initialize(agent_name) @agent_name = agent_name @event_handlers = {} # { event_type => block } = { max_concurrent: nil, timeout: 60, fire_and_forget: true, } end |
Instance Attribute Details
#agent_name ⇒ Object (readonly)
Returns the value of attribute agent_name.
15 16 17 |
# File 'lib/swarm_sdk/observer/config.rb', line 15 def agent_name @agent_name end |
#event_handlers ⇒ Object (readonly)
Returns the value of attribute event_handlers.
15 16 17 |
# File 'lib/swarm_sdk/observer/config.rb', line 15 def event_handlers @event_handlers end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/swarm_sdk/observer/config.rb', line 15 def end |
Instance Method Details
#add_handler(event_type) {|Hash| ... } ⇒ void
This method returns an undefined value.
Add an event handler for a specific event type
The block receives the event hash and should return:
- A prompt string to trigger the observer agent
- nil to skip execution for this event
40 41 42 |
# File 'lib/swarm_sdk/observer/config.rb', line 40 def add_handler(event_type, &block) @event_handlers[event_type] = block end |