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
ScriptedToolwith full schemas in its system prompt. -
WithDiscovery: Returns two tools — a
ScriptedToolwith compact prompt (no schemas) + aDiscoverToolfor runtime schema discovery viadiscoverandhelpbuiltins.
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
impl ScriptingToolSet
Sourcepub fn builder(name: impl Into<String>) -> ScriptingToolSetBuilder
pub fn builder(name: impl Into<String>) -> ScriptingToolSetBuilder
Create a builder with the given tool name.
Sourcepub fn discovery_mode(&self) -> DiscoveryMode
pub fn discovery_mode(&self) -> DiscoveryMode
Current discovery mode.
Sourcepub fn take_last_execution_trace(&self) -> Option<ScriptedExecutionTrace>
pub fn take_last_execution_trace(&self) -> Option<ScriptedExecutionTrace>
Return and clear the trace from the most recent execute call.
Auto Trait Implementations§
impl !RefUnwindSafe for ScriptingToolSet
impl !UnwindSafe for ScriptingToolSet
impl Freeze for ScriptingToolSet
impl Send for ScriptingToolSet
impl Sync for ScriptingToolSet
impl Unpin for ScriptingToolSet
impl UnsafeUnpin for ScriptingToolSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more