mod crate_sources_mcp;
mod eg;
mod research_agent;
mod state;
use anyhow::Result;
use sacp::component::Component;
use sacp_proxy::{AcpProxyExt, McpServiceRegistry};
use state::ResearchState;
use std::sync::Arc;
pub async fn run() -> Result<()> {
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),
)
.init();
tracing::info!("Starting rust-crate-sources-proxy");
CrateSourcesProxy.serve(sacp_tokio::Stdio::new()).await?;
Ok(())
}
pub struct CrateSourcesProxy;
impl Component for CrateSourcesProxy {
async fn serve(self, client: impl Component) -> Result<(), sacp::Error> {
let state = Arc::new(ResearchState::new());
let mcp_registry = McpServiceRegistry::default().with_mcp_server(
"rust-crate-query",
research_agent::build_server(state.clone()),
)?;
sacp::JrHandlerChain::new()
.name("rust-crate-sources-proxy")
.provide_mcp(mcp_registry)
.with_handler(research_agent::PermissionAutoApprover::new(state.clone()))
.proxy()
.connect_to(client)?
.serve()
.await
}
}