Class: Aiko::Tools::RunCommand
- Inherits:
-
Base
- Object
- Base
- Aiko::Tools::RunCommand
show all
- Defined in:
- lib/aiko/tools/run_command.rb
Constant Summary
collapse
- DEFAULT_TIMEOUT =
60
- MAX_TIMEOUT =
600
Constants inherited
from Base
Base::OUTPUT_LIMIT
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#approval_message(arguments) ⇒ Object
53
54
55
|
# File 'lib/aiko/tools/run_command.rb', line 53
def approval_message(arguments)
"run_command: #{arguments["command"]}"
end
|
#call(arguments) ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/aiko/tools/run_command.rb', line 38
def call(arguments)
command = arguments.fetch("command")
timeout = [(arguments["timeout"] || DEFAULT_TIMEOUT).to_i, MAX_TIMEOUT].min
timeout = DEFAULT_TIMEOUT unless timeout.positive?
output, status = run_with_timeout(command, timeout)
return "Error: command timed out after #{timeout} seconds" unless status
truncate("exit status: #{status.exitstatus}\n--- output ---\n#{output}")
end
|
#description ⇒ Object
15
16
17
18
19
|
# File 'lib/aiko/tools/run_command.rb', line 15
def description
"Run a shell command in the working directory and return its combined " \
"stdout/stderr with the exit status. Use this to run tests, scripts, " \
"or inspect the environment."
end
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/aiko/tools/run_command.rb', line 21
def input_schema
{
"type" => "object",
"properties" => {
"command" => {
"type" => "string",
"description" => "Shell command to execute"
},
"timeout" => {
"type" => "integer",
"description" => "Timeout in seconds (default: 60, max: 600)"
}
},
"required" => ["command"]
}
end
|
#name ⇒ Object
11
12
13
|
# File 'lib/aiko/tools/run_command.rb', line 11
def name
"run_command"
end
|
#requires_approval?(_arguments) ⇒ Boolean
49
50
51
|
# File 'lib/aiko/tools/run_command.rb', line 49
def requires_approval?(_arguments)
true
end
|