winx_code_agent/
server.rs1mod agents;
7mod catalog;
8mod client_profile;
9mod coherence;
10mod executions;
11mod handler;
12mod mutations;
13mod outcomes;
14mod principal;
15mod recovery;
16mod result_delivery;
17mod sessions;
18mod tasks;
19mod tool_dispatch;
20mod usage;
21mod wait_budget;
22mod workflow_types;
23
24#[cfg(test)]
25mod tests;
26
27use std::sync::Arc;
28
29use rmcp::{
30 transport::{async_rw::AsyncRwTransport, stdio},
31 ServiceExt,
32};
33use tokio::sync::Mutex;
34use tracing::info;
35
36use crate::runtime::{configured_shell_runtime, ShellRuntime};
37use crate::state::task_state::TaskRegistry;
38use crate::state::BashState;
39use sessions::SessionRegistry;
40
41pub use sessions::SessionIsolation;
42
43#[doc(hidden)]
45pub use catalog::build_tool_catalog_uncached;
46
47pub type SharedBashState = Arc<Mutex<Option<BashState>>>;
49
50#[derive(Clone)]
52pub struct WinxService {
53 sessions: Arc<Mutex<SessionRegistry>>,
54 tasks: Arc<Mutex<TaskRegistry>>,
55 root_bootstrap: Arc<Mutex<()>>,
56 shell_runtime: Arc<dyn ShellRuntime>,
57 mutations: mutations::MutationCoordinator,
58 execution_history: Arc<executions::history::WorkflowHistory>,
59 pub version: String,
61 isolation: SessionIsolation,
62}
63
64pub async fn start_winx_server() -> Result<(), Box<dyn std::error::Error>> {
66 Box::pin(start_winx_server_with_runtime(configured_shell_runtime().await?)).await
67}
68
69pub async fn start_winx_server_with_runtime(
71 runtime: Arc<dyn ShellRuntime>,
72) -> Result<(), Box<dyn std::error::Error>> {
73 info!("Starting Winx MCP Server");
74 let service = WinxService::with_runtime(SessionIsolation::Lenient, runtime);
75 let (stdin, stdout) = stdio();
76 let transport = AsyncRwTransport::new_server(stdin, stdout);
77 let server = Box::pin(service.serve(transport)).await?;
78 server.waiting().await?;
79 Ok(())
80}