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(
args["message"].as_str().unwrap_or_default(),
))
}
}Re-exports§
pub use async_ops::AsyncControl;pub use async_ops::AsyncControls;pub use async_ops::AsyncOperationKind;pub use async_ops::AsyncOperationSignalKind;pub use async_ops::AsyncOperationStartReceipt;pub use async_ops::AsyncOperationStatus;pub use async_ops::INSPECT_TOOL_NAME;pub use async_ops::InspectOperationsArgs;pub use async_ops::SEND_INPUT_TOOL_NAME;pub use async_ops::STOP_TOOL_NAME;pub use async_ops::SendOperationInputArgs;pub use async_ops::StopOperationsArgs;pub use async_ops::WAIT_TOOL_NAME;pub use async_ops::WaitOperationsArgs;pub use async_ops::deserialize_u64_from_json_number;pub use async_ops::deserialize_usize_from_json_number;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§
- Artifact
Id - Immutable artifact identity.
- Artifact
Input - Durable, unresolved artifact input carried through tools and conversations.
- Artifact
Instruction - Optional, bounded instruction associated with an artifact input.
- Artifact
Ref - Storage-neutral reference to one immutable artifact revision.
- Artifact
Size - Authoritative plaintext byte length of an immutable artifact.
- Media
Type - Parsed, concrete MIME type for immutable artifact plaintext.
- Sha256
Digest - Canonical SHA-256 digest in
sha256:<hex>form. - Tool
Call - A tool call requested by the LLM.
- Tool
Output - Ordered, serializable tool output without decrypted bytes or host paths.
- 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§
- Artifact
Input Source - Origin of an artifact in an agent input.
- 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.
- Tool
Output Part - One ordered part of a tool’s durable output.
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.