#[cfg(feature = "comms")]
pub mod comms;
pub mod composite;
pub mod config;
#[cfg(not(target_arch = "wasm32"))]
pub mod file_store;
pub mod memory_store;
#[cfg(not(target_arch = "wasm32"))]
pub mod project;
#[cfg(not(target_arch = "wasm32"))]
pub mod shell;
#[cfg(feature = "skills")]
pub mod skills;
pub mod store;
#[cfg(all(feature = "sub-agents", not(target_arch = "wasm32")))]
pub mod sub_agent;
pub mod tasks;
pub mod types;
pub mod utility;
#[cfg(feature = "comms")]
pub use comms::CommsToolSurface;
pub use composite::{CompositeDispatcher, CompositeDispatcherError};
pub use config::{
BuiltinToolConfig, EnforcedToolPolicy, ResolvedToolPolicy, ToolMode, ToolPolicyLayer,
};
#[cfg(not(target_arch = "wasm32"))]
pub use file_store::FileTaskStore;
pub use memory_store::MemoryTaskStore;
#[cfg(not(target_arch = "wasm32"))]
pub use project::{ensure_rkat_dir, ensure_rkat_dir_async, find_project_root};
pub use store::TaskStore;
use async_trait::async_trait;
use meerkat_core::ToolDef;
use serde_json::Value;
use std::sync::Arc;
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait BuiltinTool: Send + Sync {
fn name(&self) -> &'static str;
fn def(&self) -> ToolDef;
fn default_enabled(&self) -> bool;
async fn call(&self, args: Value) -> Result<Value, BuiltinToolError>;
}
#[derive(Clone)]
pub struct BuiltinToolEntry {
pub tool: Arc<dyn BuiltinTool>,
pub enabled: bool,
}
impl BuiltinToolEntry {
pub fn new(tool: Arc<dyn BuiltinTool>) -> Self {
let enabled = tool.default_enabled();
Self { tool, enabled }
}
pub fn with_enabled(tool: Arc<dyn BuiltinTool>, enabled: bool) -> Self {
Self { tool, enabled }
}
}
#[derive(Debug, thiserror::Error)]
pub enum BuiltinToolError {
#[error("Invalid arguments: {0}")]
InvalidArgs(String),
#[error("Execution failed: {0}")]
ExecutionFailed(String),
#[error("Task error: {0}")]
TaskError(String),
}
impl BuiltinToolError {
pub fn invalid_args(msg: impl Into<String>) -> Self {
Self::InvalidArgs(msg.into())
}
pub fn execution_failed(msg: impl Into<String>) -> Self {
Self::ExecutionFailed(msg.into())
}
pub fn task_error(msg: impl Into<String>) -> Self {
Self::TaskError(msg.into())
}
}