use std::path::{Path, PathBuf};
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
pub mod cli_tool;
pub mod http_server;
pub mod mcp_server;
pub mod generic;
pub mod http_server_impl;
pub use http_server_impl::{HttpServerGenerator, HttpServerConfig};
use crate::error::Result;
pub trait WrapperGenerator {
fn generate_wrapper(&self, spec: &WrapperSpec) -> Result<String>;
fn compile_wrapper(&self, code: &str, output_path: &Path) -> Result<()>;
fn generate_and_compile(
&self,
spec: &WrapperSpec,
output_path: &Path,
) -> Result<()> {
let code = self.generate_wrapper(spec)?;
self.compile_wrapper(&code, output_path)
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ApplicationType {
HttpServer { port: u16 },
McpServer { port: u16, schema_path: Option<PathBuf> },
CliTool { interactive: bool },
Generic,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CommunicationSpec {
pub protocol: CommunicationProtocol,
pub channels: Vec<String>,
pub rpc_functions: HashMap<String, String>,
}
impl Default for CommunicationSpec {
fn default() -> Self {
Self {
protocol: CommunicationProtocol::Json,
channels: vec!["default".to_string()],
rpc_functions: HashMap::new(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum CommunicationProtocol {
Json,
MessagePack,
Custom(String),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WrapperSpec {
pub app_type: ApplicationType,
pub app_path: PathBuf,
pub arguments: Vec<String>,
pub environment: HashMap<String, String>,
pub working_directory: Option<PathBuf>,
pub communication: CommunicationSpec,
pub template_variables: HashMap<String, String>,
}