Expand description
ScriptedTool and the ToolDef layer for bashkit.
Compose ToolDef + callback pairs into one LLM Tool
that accepts a bash script. Each registered tool becomes a command inside a
logic-only shell, so a model can orchestrate many calls in one turn with
pipes, variables, loops and jq.
ScriptedTool: the LLM tool. Build withScriptedTool::builder.ScriptingToolSet: ScriptedTool plus optional discovery tool.ToolRegistry: one set of tool definitions shared by the shell, embedded Python and embedded TypeScript. Install into anyBashBuilderwithToolRegistry::install.ToolDefExtension: the shell surface alone, as a bashkitExtension.
use bashkit::Tool;
use bashkit_scripted_tool::{ScriptedTool, ToolArgs, ToolDef};
let tool = ScriptedTool::builder("api")
.tool_fn(
ToolDef::new("greet", "Greet a user"),
|args: &ToolArgs| Ok(format!("hello {}\n", args.param_str("name").unwrap_or("world"))),
)
.build();
let output = tool
.execution(serde_json::json!({"commands": "greet --name Alice"}))
.unwrap()
.execute()
.await
.unwrap();
assert_eq!(output.result["stdout"], "hello Alice\n");Moved out of the bashkit crate (formerly feature scripted_tool). See
docs/migrating-scripted-tool.md in the repository for the migration.
Structs§
- Discover
Tool - A
Toolthat exposes onlydiscoverandhelpbuiltins for runtime schema discovery. Returned byScriptingToolSet::toolsinDiscoveryMode::WithDiscoverymode alongside the main script tool. - Scripted
Command Invocation - One builtin/tool invocation inside a scripted tool execute.
- Scripted
Execution Trace - Inner execution trace captured for the last
ScriptedTool::execute()call. - Scripted
Tool - A
Toolthat orchestrates multiple tools via bash scripts. - Scripted
Tool Builder - Builder for
ScriptedTool. - Scripting
Tool Set - Higher-level wrapper around
ScriptedToolwith mode-controlled tool exposure. - Scripting
Tool SetBuilder - Builder for
ScriptingToolSet. - Tool
Args - Parsed arguments passed to a tool exec function.
- Tool
Call - Immutable data supplied to the approval/policy hook.
- Tool
Call Request - Per-
exec*registry context carried throughbashkit::ExecutionExtensions. - ToolDef
- OpenAPI-style tool definition: name, description, input schema.
- Tool
DefExtension - Bash extension that registers ToolDef-backed commands plus
helpanddiscover. - Tool
DefExtension Builder - Builder for
ToolDefExtension. - Tool
DefInvocation Trace - Explicit handle for reading and clearing one extension’s invocation trace.
- Tool
Impl - Complete tool: definition + sync/async exec functions.
- Tool
Registry - Tool
Registry Builder
Enums§
- Callback
Kind - Sync or async callback for a registered tool.
- Discovery
Mode - Controls how
ScriptingToolSet::toolsexposes tool information to the LLM. - Scripted
Command Kind - Kind of inner command invocation recorded during a
ScriptedToolexecute. - Tool
Call Decision - Result of the registry’s approval/policy hook.
- Tool
Call Surface - Runtime surface that initiated a registry call.
Type Aliases§
- Async
Tool Callback - Alias for
AsyncToolExec(backward compatibility). - Async
Tool Exec - Asynchronous execution function for a tool.
- Sync
Tool Exec - Synchronous execution function for a tool.
- Tool
Callback - Alias for
SyncToolExec(backward compatibility).