use std::path::PathBuf;
use crate::compression::engine::Tool;
use crate::Error;
#[derive(Debug, Clone)]
pub struct GeneratorConfig {
pub cli_name: String,
pub bridge_url: String,
pub token: String,
pub tools: Vec<Tool>,
pub session_pid: u32,
pub output_dir: PathBuf,
}
pub trait ClientGenerator {
fn generate(&self, config: &GeneratorConfig) -> Result<Vec<PathBuf>, Error>;
}
#[cfg(test)]
pub mod test_helpers {
use crate::compression::engine::Tool;
use serde_json::json;
use std::path::Path;
use super::GeneratorConfig;
pub fn make_config(output_dir: &Path) -> GeneratorConfig {
GeneratorConfig {
cli_name: "my-server".to_string(),
bridge_url: "http://127.0.0.1:51234".to_string(),
token: "a3f7deadbeefa3f7deadbeefa3f7deadbeefa3f7deadbeefa3f7deadbeef1234".to_string(),
tools: vec![
Tool::new(
"fetch",
Some("Fetch a URL.".to_string()),
json!({
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "URL to fetch."
},
"timeout": {
"type": "integer",
"description": "Timeout in seconds.",
"default": 30
},
"method": {
"type": "string",
"description": "HTTP method to use.",
"enum": ["GET", "POST"],
"default": "GET"
}
},
"required": ["url"]
}),
),
Tool::new(
"search",
Some("Search the web.".to_string()),
json!({
"type": "object",
"properties": { "query": { "type": "string" } },
"required": ["query"]
}),
),
],
session_pid: 12345,
output_dir: output_dir.to_path_buf(),
}
}
pub fn make_config_multiword_tool(output_dir: &Path) -> GeneratorConfig {
let mut cfg = make_config(output_dir);
cfg.tools = vec![Tool::new(
"get_confluence_page",
Some("Retrieve a Confluence page by ID.".to_string()),
json!({
"type": "object",
"properties": {
"page_id": { "type": "string" },
"space_key": { "type": "string" }
},
"required": ["page_id"]
}),
)];
cfg
}
}