Skip to main content

Crate bashkit_scripted_tool

Crate bashkit_scripted_tool 

Source
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.

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§

DiscoverTool
A Tool that exposes only discover and help builtins for runtime schema discovery. Returned by ScriptingToolSet::tools in DiscoveryMode::WithDiscovery mode alongside the main script tool.
ScriptedCommandInvocation
One builtin/tool invocation inside a scripted tool execute.
ScriptedExecutionTrace
Inner execution trace captured for the last ScriptedTool::execute() call.
ScriptedTool
A Tool that orchestrates multiple tools via bash scripts.
ScriptedToolBuilder
Builder for ScriptedTool.
ScriptingToolSet
Higher-level wrapper around ScriptedTool with mode-controlled tool exposure.
ScriptingToolSetBuilder
Builder for ScriptingToolSet.
ToolArgs
Parsed arguments passed to a tool exec function.
ToolCall
Immutable data supplied to the approval/policy hook.
ToolCallRequest
Per-exec* registry context carried through bashkit::ExecutionExtensions.
ToolDef
OpenAPI-style tool definition: name, description, input schema.
ToolDefExtension
Bash extension that registers ToolDef-backed commands plus help and discover.
ToolDefExtensionBuilder
Builder for ToolDefExtension.
ToolDefInvocationTrace
Explicit handle for reading and clearing one extension’s invocation trace.
ToolImpl
Complete tool: definition + sync/async exec functions.
ToolRegistry
ToolRegistryBuilder

Enums§

CallbackKind
Sync or async callback for a registered tool.
DiscoveryMode
Controls how ScriptingToolSet::tools exposes tool information to the LLM.
ScriptedCommandKind
Kind of inner command invocation recorded during a ScriptedTool execute.
ToolCallDecision
Result of the registry’s approval/policy hook.
ToolCallSurface
Runtime surface that initiated a registry call.

Type Aliases§

AsyncToolCallback
Alias for AsyncToolExec (backward compatibility).
AsyncToolExec
Asynchronous execution function for a tool.
SyncToolExec
Synchronous execution function for a tool.
ToolCallback
Alias for SyncToolExec (backward compatibility).