arsenal-sdk · tool_caller
Declared module signatures, types, configuration, and source documentation.
Source: arsenal/crates/arsenal-sdk/src/tool_caller.rs. SHA-256: 20def8c456e3c475caa03ec679b3be2c1055286604feb2c92095814f67a34d10.
This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.
tool_caller::Tool
Tool trait for implementing callable tools
pub trait Tool: Send + Sync {
/// Get the tool's unique identifier
fn id(&self) -> &str;
/// Get the tool's description
fn description(&self) -> &str;
/// Get the required scope pattern for this tool
fn required_scope(&self) -> &str;
/// Get available methods
fn methods(&self) -> &[&str];
/// Execute a method on this tool
///
/// # Errors
/// Returns an error if the method is not found or execution fails
fn execute(&self, method: &str, params: serde_json::Value) -> ArsenalResult<serde_json::Value>;
}Source line: 16.
tool_caller::ToolCallRequest
Request to call a tool
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolCallRequest {
/// Tool identifier
pub tool_id: String,
/// Method to call
pub method: String,
/// Parameters
pub params: serde_json::Value,
/// Request ID for tracing
pub request_id: Option<String>
}Source line: 38.
tool_caller::ToolCallRequest::new
Create a new tool call request
#[must_use]
pub fn new(tool_id: impl Into<String>, method: impl Into<String>) -> Self;Source line: 52.
tool_caller::ToolCallRequest::with_params
Set parameters
#[must_use]
pub fn with_params(mut self, params: serde_json::Value) -> Self;Source line: 63.
tool_caller::ToolCallRequest::with_request_id
Set request ID
#[must_use]
pub fn with_request_id(mut self, request_id: impl Into<String>) -> Self;Source line: 70.
tool_caller::ToolCallResponse
Response from a tool call
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolCallResponse {
/// Whether the call succeeded
pub success: bool,
/// Response data
pub data: serde_json::Value,
/// Error message if failed
pub error: Option<String>,
/// Request ID if provided
pub request_id: Option<String>
}Source line: 78.
tool_caller::ToolCallResponse::success
Create a successful response
#[must_use]
pub fn success(data: serde_json::Value) -> Self;Source line: 92.
tool_caller::ToolCallResponse::error
Create an error response
#[must_use]
pub fn error(message: impl Into<String>) -> Self;Source line: 103.
tool_caller::ToolCallResponse::with_request_id
Set request ID
#[must_use]
pub fn with_request_id(mut self, request_id: impl Into<String>) -> Self;Source line: 114.
tool_caller::ToolCaller
Tool caller for invoking tools with capability checking
pub struct ToolCaller {
}Source line: 121.
tool_caller::ToolCaller::new
Create a new tool caller
#[must_use]
pub fn new() -> Self;Source line: 131.
tool_caller::ToolCaller::register_tool
Register a tool
pub fn register_tool(&mut self, tool: Arc<dyn Tool>);Source line: 139.
tool_caller::ToolCaller::unregister_tool
Unregister a tool
pub fn unregister_tool(&mut self, tool_id: &str);Source line: 144.
tool_caller::ToolCaller::get_tool
Get a registered tool
#[must_use]
pub fn get_tool(&self, tool_id: &str) -> Option<Arc<dyn Tool>>;Source line: 150.
tool_caller::ToolCaller::tool_ids
List registered tool IDs
#[must_use]
pub fn tool_ids(&self) -> Vec<String>;Source line: 156.
tool_caller::ToolCaller::set_capability
Set the current capability
pub fn set_capability(&mut self, capability: Arc<CapabilityHandle>);Source line: 161.
tool_caller::ToolCaller::clear_capability
Clear the current capability
pub fn clear_capability(&mut self);Source line: 166.
tool_caller::ToolCaller::call
Call a tool
Errors
Returns an error if the tool is not found, capability is missing, or the call fails
pub fn call(&self, request: &ToolCallRequest) -> ArsenalResult<ToolCallResponse>;Source line: 175.