Class: Kward::Tools::RunShellCommand
- Defined in:
- lib/kward/tools/run_shell_command.rb
Overview
Tool wrapper for bounded shell commands in the workspace.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#call(args, _conversation, cancellation: nil) ⇒ Object
Executes the tool and returns model-facing output text.
-
#initialize(workspace:) ⇒ RunShellCommand
constructor
Builds the tool schema and stores the execution dependency.
Methods inherited from Base
Constructor Details
#initialize(workspace:) ⇒ RunShellCommand
Builds the tool schema and stores the execution dependency.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/kward/tools/run_shell_command.rb', line 11 def initialize(workspace:) @workspace = workspace super( "run_shell_command", "Run a shell command from the workspace root.", properties: { command: { type: "string", description: "Command to run." }, timeout_seconds: { type: "integer", description: "Timeout seconds; default 30." } }, required: ["command"] ) end |
Instance Method Details
#call(args, _conversation, cancellation: nil) ⇒ Object
Executes the tool and returns model-facing output text.
25 26 27 28 29 30 |
# File 'lib/kward/tools/run_shell_command.rb', line 25 def call(args, _conversation, cancellation: nil) command = argument(args, :command, "") timeout_seconds = argument(args, :timeout_seconds, Workspace::DEFAULT_COMMAND_TIMEOUT_SECONDS) @workspace.run_shell_command(command, timeout_seconds: timeout_seconds, cancellation: cancellation) end |