Skip to main content

ScriptingToolSet

Struct ScriptingToolSet 

Source
pub struct ScriptingToolSet { /* private fields */ }
Expand description

Higher-level wrapper around ScriptedTool with mode-controlled tool exposure.

Use ScriptingToolSet::tools to get the tools to register with your LLM:

  • Exclusive (default): Returns one tool — a ScriptedTool with full schemas in its system prompt.

  • WithDiscovery: Returns two tools — a ScriptedTool with compact prompt (no schemas) + a DiscoverTool for runtime schema discovery via discover and help builtins.

use bashkit::{Tool, ToolRequest};
use bashkit_scripted_tool::{ScriptingToolSet, ToolArgs, ToolDef};

// Exclusive mode (default): one tool with full schemas
let toolset = ScriptingToolSet::builder("api")
    .tool_fn(
        ToolDef::new("greet", "Greet someone")
            .with_schema(serde_json::json!({
                "type": "object",
                "properties": { "name": {"type": "string"} }
            })),
        |args: &ToolArgs| Ok(format!("hello {}\n", args.param_str("name").unwrap_or("world"))),
    )
    .build();

let tools = toolset.tools();
assert_eq!(tools.len(), 1);
assert!(tools[0].system_prompt().contains("--name <string>"));

let resp = tools[0].execute(ToolRequest {
    commands: "greet --name Alice".into(),
    timeout_ms: None,
}).await;
assert_eq!(resp.stdout.trim(), "hello Alice");
use bashkit::Tool;
use bashkit_scripted_tool::{ScriptingToolSet, ToolArgs, ToolDef};

// Discovery mode: two tools
let toolset = ScriptingToolSet::builder("api")
    .tool_fn(
        ToolDef::new("greet", "Greet someone"),
        |_args: &ToolArgs| Ok("hello\n".to_string()),
    )
    .with_discovery()
    .build();

let tools = toolset.tools();
assert_eq!(tools.len(), 2);
assert_eq!(tools[0].name(), "api");
assert_eq!(tools[1].name(), "api_discover");

Implementations§

Source§

impl ScriptingToolSet

Source

pub fn builder(name: impl Into<String>) -> ScriptingToolSetBuilder

Create a builder with the given tool name.

Source

pub fn discovery_mode(&self) -> DiscoveryMode

Current discovery mode.

Source

pub fn take_last_execution_trace(&self) -> Option<ScriptedExecutionTrace>

Return and clear the trace from the most recent execute call.

Source

pub fn tools(&self) -> Vec<Box<dyn Tool>>

Return the tools to register with the LLM.

  • Exclusive: [ScriptedTool] — one tool with full schemas in prompt.
  • WithDiscovery: [ScriptedTool, DiscoverTool] — script tool with compact prompt + discover tool for runtime schema exploration.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.