descry-tool-core 0.3.1

Core traits and types for descry-tool framework
Documentation
//! Protocol adapters for different LLM platforms
//!
//! Provides unified interface for converting tools to different protocol formats.

mod mcp;
mod openai;
mod anthropic;

pub use mcp::McpAdapter;
pub use openai::OpenAiAdapter;
pub use anthropic::AnthropicAdapter;

use serde::{de::DeserializeOwned, Serialize};

/// Protocol adapter trait
///
/// Converts tools to protocol-specific formats.
pub trait ToolAdapter: Send + Sync + 'static {
    /// Protocol-specific tool specification
    type ToolSpec: Serialize + Send + Sync;
    
    /// Protocol-specific call request
    type CallRequest: DeserializeOwned + Send + Sync;
    
    /// Protocol-specific call response
    type CallResponse: Serialize + Send + Sync;

    /// Convert ToolMeta to protocol-specific tool spec
    fn to_spec(meta: &crate::ToolMeta) -> Self::ToolSpec;

    /// Extract tool name and params from protocol request
    fn from_request(req: Self::CallRequest) -> Result<(String, serde_json::Value), crate::ToolError>;

    /// Convert tool output to protocol response
    fn to_response(output: serde_json::Value) -> Self::CallResponse;
}