Class: ClaudeSwarm::BaseExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_swarm/base_executor.rb

Direct Known Subclasses

ClaudeCodeExecutor, OpenAI::Executor

Defined Under Namespace

Classes: ExecutionError, ParseError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(working_directory: Dir.pwd, model: nil, mcp_config: nil, vibe: false, instance_name: nil, instance_id: nil, calling_instance: nil, calling_instance_id: nil, claude_session_id: nil, additional_directories: [], debug: false) ⇒ BaseExecutor

Returns a new instance of BaseExecutor.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/claude_swarm/base_executor.rb', line 7

def initialize(working_directory: Dir.pwd, model: nil, mcp_config: nil, vibe: false,
  instance_name: nil, instance_id: nil, calling_instance: nil, calling_instance_id: nil,
  claude_session_id: nil, additional_directories: [], debug: false)
  @working_directory = working_directory
  @additional_directories = additional_directories
  @model = model
  @mcp_config = mcp_config
  @vibe = vibe
  @session_id = claude_session_id
  @last_response = nil
  @instance_name = instance_name
  @instance_id = instance_id
  @calling_instance = calling_instance
  @calling_instance_id = calling_instance_id
  @debug = debug

  # Setup static info strings for logging
  @instance_info = build_info(@instance_name, @instance_id)
  @caller_info = build_info(@calling_instance, @calling_instance_id)
  @caller_to_instance = "#{@caller_info} -> #{instance_info}:"
  @instance_to_caller = "#{instance_info} -> #{@caller_info}:"

  # Setup logging
  setup_logging

  # Setup static event templates
  setup_event_templates
end

Instance Attribute Details

#instance_infoObject (readonly)

Returns the value of attribute instance_info.



5
6
7
# File 'lib/claude_swarm/base_executor.rb', line 5

def instance_info
  @instance_info
end

#last_responseObject (readonly)

Returns the value of attribute last_response.



5
6
7
# File 'lib/claude_swarm/base_executor.rb', line 5

def last_response
  @last_response
end

#loggerObject (readonly)

Returns the value of attribute logger.



5
6
7
# File 'lib/claude_swarm/base_executor.rb', line 5

def logger
  @logger
end

#session_idObject (readonly)

Returns the value of attribute session_id.



5
6
7
# File 'lib/claude_swarm/base_executor.rb', line 5

def session_id
  @session_id
end

#session_json_pathObject (readonly)

Returns the value of attribute session_json_path.



5
6
7
# File 'lib/claude_swarm/base_executor.rb', line 5

def session_json_path
  @session_json_path
end

#session_pathObject (readonly)

Returns the value of attribute session_path.



5
6
7
# File 'lib/claude_swarm/base_executor.rb', line 5

def session_path
  @session_path
end

#working_directoryObject (readonly)

Returns the value of attribute working_directory.



5
6
7
# File 'lib/claude_swarm/base_executor.rb', line 5

def working_directory
  @working_directory
end

Instance Method Details

#execute(_prompt, _options = {}) ⇒ Object

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/claude_swarm/base_executor.rb', line 36

def execute(_prompt, _options = {})
  raise NotImplementedError, "Subclasses must implement the execute method"
end

#has_session?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/claude_swarm/base_executor.rb', line 45

def has_session?
  !@session_id.nil?
end

#reset_sessionObject



40
41
42
43
# File 'lib/claude_swarm/base_executor.rb', line 40

def reset_session
  @session_id = nil
  @last_response = nil
end