Skip to main content

Crate nenjo_tool_api

Crate nenjo_tool_api 

Source
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:

§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§

ToolCall
A tool call requested by the LLM.
ToolResult
Result of a tool execution.
ToolResultMessage
A tool result to feed back to the LLM.
ToolSecurity
SDK-level tool construction policy.
ToolSpec
Full specification of a tool for LLM registration.

Enums§

ToolAutonomy
High-level autonomy requested while constructing runtime tools.
ToolCategory
Classifies a tool’s side-effect profile for filtering and model guidance.
ToolOrigin
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.