Class: SkillBench::Tools::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/skill_bench/tools/dispatcher.rb

Overview

Dispatches tool execution based on the tool name, coordinating parsing and invocation.

Class Method Summary collapse

Class Method Details

.call(name, arguments, working_dir, container_id = nil) ⇒ Object

Executes a specified tool with the given arguments within a working directory.

Parameters:

  • name (String)

    The name of the tool to execute (e.g., ‘read_file’).

  • arguments (String)

    A JSON string containing the arguments for the tool.

  • working_dir (String)

    The base directory in which the tool should operate.

  • container_id (String, nil) (defaults to: nil)

    The Docker container ID for isolated execution.

Returns:

  • tool execution result or raises exception.

Raises:

  • (StandardError)

    when execution or argument parsing fails



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/skill_bench/tools/dispatcher.rb', line 21

def self.call(name, arguments, working_dir, container_id = nil)
  args = ArgumentParser.call(arguments)
  return args if args.is_a?(Hash) && args[:success] == false

  working_dir_path = Pathname.new(working_dir).expand_path

  execute_tool(name, args, working_dir_path, container_id)
rescue StandardError => e
  log_error(e)
  raise
end