Module: LLM::Tool::Utils

Included in:
Git, Rg, Shell
Defined in:
lib/llm/tools/utils.rb

Overview

Shared utilities for tool implementations.

Instance Method Summary collapse

Instance Method Details

#nowNumeric

Returns:

  • (Numeric)


27
28
29
# File 'lib/llm/tools/utils.rb', line 27

def now
  Process.clock_gettime(Process::CLOCK_MONOTONIC)
end

#wait(command:, timeout:) ⇒ void

This method returns an undefined value.

Wait for a command to finish, or abort with an error when it exceeds the specified timeout.

Parameters:

  • command (Test::Cmd)
  • timeout (Integer)


14
15
16
17
18
19
20
21
22
23
# File 'lib/llm/tools/utils.rb', line 14

def wait(command:, timeout:)
  start = now
  while command.running?
    if now - start > timeout
      command.kill!
      raise "command timed out after #{timeout}s"
    end
    sleep 0.01
  end
end