Expand description
Shared tool contracts for Nenjo agents, model providers, and runtimes.
This crate owns the common tool API surface used across the Nenjo workspace. It is deliberately independent from the rest of the workspace so model integrations, SDK code, and worker runtimes can agree on tool schemas and execution results without depending on each other.
The main entry points are:
Tool, the async trait implemented by concrete tool runtimes.ToolSpec, the JSON-schema-backed metadata sent to model providers.ToolCategory, the side-effect classification used for guidance and filtering.ToolCall,ToolResult, andToolResultMessage, the request and result payloads that flow through tool execution.ToolAutonomyandToolSecurity, the SDK-level policy inputs used when constructing tools.
§Example
use async_trait::async_trait;
use serde_json::json;
use nenjo_tool_api::{Tool, ToolCategory, ToolResult};
struct EchoTool;
#[async_trait]
impl Tool for EchoTool {
fn name(&self) -> &str {
"echo"
}
fn description(&self) -> &str {
"Echoes a message back to the caller."
}
fn parameters_schema(&self) -> serde_json::Value {
json!({
"type": "object",
"properties": {
"message": { "type": "string" }
},
"required": ["message"]
})
}
fn category(&self) -> ToolCategory {
ToolCategory::Read
}
async fn execute(&self, args: serde_json::Value) -> anyhow::Result<ToolResult> {
Ok(ToolResult {
success: true,
output: args["message"].as_str().unwrap_or_default().to_string(),
error: None,
})
}
}Re-exports§
pub use async_ops::AsyncOperationKind;pub use async_ops::AsyncOperationSignalKind;pub use async_ops::AsyncOperationStatus;pub use async_ops::INSPECT_OPERATIONS_TOOL_NAME;pub use async_ops::InspectOperationsArgs;pub use async_ops::SEND_OPERATION_INPUT_TOOL_NAME;pub use async_ops::STOP_OPERATIONS_TOOL_NAME;pub use async_ops::SendOperationInputArgs;pub use async_ops::StopOperationsArgs;pub use async_ops::WAIT_OPERATIONS_TOOL_NAME;pub use async_ops::WaitOperationsArgs;pub use async_ops::inspect_operations_parameters_schema;pub use async_ops::send_operation_input_parameters_schema;pub use async_ops::stop_operations_parameters_schema;pub use async_ops::wait_operations_parameters_schema;
Modules§
- async_
ops - Shared contracts for model-visible async operation tools.
Structs§
- Tool
Call - A tool call requested by the LLM.
- Tool
Result - Result of a tool execution.
- Tool
Result Message - A tool result to feed back to the LLM.
- Tool
Security - SDK-level tool construction policy.
- Tool
Spec - Full specification of a tool for LLM registration.
Enums§
- Tool
Autonomy - High-level autonomy requested while constructing runtime tools.
- Tool
Category - Classifies a tool’s side-effect profile for filtering and model guidance.
- Tool
Origin - Runtime ownership surface for a tool.
Traits§
- Tool
- Core tool trait for agent capabilities.
Functions§
- sanitize_
tool_ name - Sanitize a tool function name to match the strict OpenAI pattern
^[a-zA-Z0-9_-]+$. - sanitize_
tool_ name_ lenient - Light sanitization for lenient providers (Ollama) while preserving dots used in MCP namespaced tool names.