Skip to main content

Crate agentkit_tool_shell

Crate agentkit_tool_shell 

Source
Expand description

Shell execution tool for agentkit agent loops.

This crate provides ShellExecTool, a tool that spawns subprocesses and captures their stdout, stderr, exit code, and success status. It supports custom working directories, environment variables, per-invocation timeouts, and cooperative turn cancellation through agentkit_tools_core::ToolContext.

The easiest way to get started is with the registry() helper, which returns a ToolRegistry pre-loaded with the shell.exec tool.

Pair the tool with CommandPolicy from agentkit-tools-core when you need fine-grained control over which executables, working directories, and environment variables are permitted.

§Example

use agentkit_tool_shell::{registry, ShellExecTool};
use agentkit_tools_core::Tool;

// Build a registry that contains the shell.exec tool.
let reg = registry();
let specs = reg.specs();
assert!(specs.iter().any(|s| s.name.0 == "shell.exec"));

// Or construct the tool manually and register it yourself.
let tool = ShellExecTool::default();
assert_eq!(tool.spec().name.0, "shell.exec");

Structs§

ShellExecTool
A tool that executes shell commands as subprocesses.

Functions§

registry
Creates a ToolRegistry pre-populated with ShellExecTool.