Class: OllamaAgent::Runtime::IntentTranslator

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama_agent/runtime/intent_translator.rb

Overview

Maps Agent tool call payloads to KernelPipeline intent hashes (incl. expected_pre_hash). rubocop:disable Metrics/ClassLength – one module per tool family; kept explicit for review

Constant Summary collapse

TOOL_TO_METHOD =
{
  "write_file" => :translate_write_file,
  "edit_file" => :translate_edit_file,
  "apply_patch" => :translate_apply_patch,
  "delete_file" => :translate_delete_file,
  "rename_file" => :translate_rename_file,
  "move_file" => :translate_rename_file
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(workspace_root:) ⇒ IntentTranslator

Returns a new instance of IntentTranslator.



23
24
25
# File 'lib/ollama_agent/runtime/intent_translator.rb', line 23

def initialize(workspace_root:)
  @root = File.expand_path(workspace_root.to_s)
end

Instance Method Details

#translate(tool_call:) ⇒ Hash

Returns intent for KernelPipeline#execute.

Parameters:

  • tool_call (Hash)

    keys name / “name” and arguments / “arguments”

Returns:

Raises:

  • (ArgumentError)


29
30
31
32
33
34
35
# File 'lib/ollama_agent/runtime/intent_translator.rb', line 29

def translate(tool_call:)
  tc = normalize_tool_call(tool_call)
  meth = TOOL_TO_METHOD[tc[:name]]
  raise ArgumentError, "IntentTranslator does not support tool #{tc[:name].inspect}" unless meth

  send(meth, tc[:arguments])
end