Skip to main content

Module tool

Module tool 

Source
Expand description

Tool contract for LLM integration Tool contract and BashTool implementation.

§Public Library Contract

bashkit follows the Everruns toolkit-library contract:

ToolBuilder (config) -> Tool (metadata) -> ToolExecution (single-use runtime)

BashToolBuilder configures a reusable tool definition. BashTool exposes locale-aware metadata plus Tool::execution for validated, single-use runs. ToolExecution returns structured ToolOutput and can optionally stream ToolOutputChunk values during execution.

§Architecture

  • Tool trait: shared metadata + execution contract
  • BashToolBuilder: reusable builder for config, schemas, OpenAI tool JSON, and tower::Service integration
  • BashTool: immutable metadata object implementing Tool
  • ToolExecution: validated, single-use runtime for one call

§Builder Example

use bashkit::{BashTool, Tool};

let builder = BashTool::builder()
    .locale("en-US")
    .username("agent")
    .hostname("sandbox");

let tool = builder.build();
assert_eq!(tool.name(), "bashkit");
assert_eq!(tool.display_name(), "Bash");
assert!(builder.build_tool_definition()["function"]["parameters"].is_object());

§Execution Example

use bashkit::{BashTool, Tool};
use futures::StreamExt;

let tool = BashTool::default();
let execution = tool
    .execution(serde_json::json!({"commands": "printf 'a\nb\n'"}))
    .expect("valid args");
let mut stream = execution.output_stream().expect("stream available");

let handle = tokio::spawn(async move { execution.execute().await.expect("execution succeeds") });
let first = stream.next().await.expect("first chunk");
assert_eq!(first.kind, "stdout");
assert!(first.data.as_str().is_some_and(|chunk| chunk.starts_with("a\n")));

let output = handle.await.expect("join");
assert_eq!(output.result["stdout"], "a\nb\n");

Structs§

BashTool
Virtual bash interpreter implementing the Tool trait
BashToolBuilder
Builder for configuring BashTool
ToolExecution
Stateful, single-use tool execution.
ToolImage
Image payload returned by a tool.
ToolOutput
Structured execution result.
ToolOutputChunk
Incremental tool output chunk.
ToolOutputMetadata
Consumer-facing metadata that never goes to the LLM.
ToolOutputStream
Stream returned by ToolExecution::output_stream.
ToolRequest
Request to execute bash commands
ToolResponse
Response from executing a bash script
ToolStatus
Status update during tool execution

Enums§

ToolError
Tool execution error.

Constants§

VERSION
Library version from Cargo.toml

Traits§

Tool
Tool contract for LLM integration.

Type Aliases§

ToolService
Standard tower::Service type for toolkit integrations.