Add extensible tool system with code execution and web search
Introduces a tool registry architecture with sandboxed code execution, web search capabilities, and consent-based permission management. Enables safe, pluggable LLM tool integration with schema validation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
53
crates/owlen-core/src/tools/mod.rs
Normal file
53
crates/owlen-core/src/tools/mod.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use serde_json::Value;
|
||||
|
||||
pub mod code_exec;
|
||||
pub mod registry;
|
||||
pub mod web_search;
|
||||
pub mod web_search_detailed;
|
||||
|
||||
#[async_trait]
|
||||
pub trait Tool: Send + Sync {
|
||||
fn name(&self) -> &'static str;
|
||||
fn description(&self) -> &'static str;
|
||||
fn schema(&self) -> Value;
|
||||
fn requires_network(&self) -> bool {
|
||||
false
|
||||
}
|
||||
fn requires_filesystem(&self) -> Vec<String> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value) -> Result<ToolResult>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ToolResult {
|
||||
pub success: bool,
|
||||
pub output: Value,
|
||||
pub duration: std::time::Duration,
|
||||
pub metadata: HashMap<String, String>,
|
||||
}
|
||||
|
||||
impl ToolResult {
|
||||
pub fn success(output: Value) -> Self {
|
||||
Self {
|
||||
success: true,
|
||||
output,
|
||||
duration: std::time::Duration::from_millis(0),
|
||||
metadata: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn error(message: &str) -> Self {
|
||||
Self {
|
||||
success: false,
|
||||
output: serde_json::json!({ "error": message }),
|
||||
duration: std::time::Duration::from_millis(0),
|
||||
metadata: HashMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user