Skip to main content

winx_code_agent/daemon/
mod.rs

1//! Long-lived shell daemon and its JSON-RPC Unix-socket client.
2
3mod client;
4mod control;
5mod lifecycle;
6mod protocol;
7mod server;
8
9use std::path::PathBuf;
10
11pub use client::{DaemonClient, DaemonShellRuntime};
12pub use control::ControlServer;
13pub use protocol::{
14    HelloResult, JournalRead, PruneResult, SessionInfo, COMPACT_ACTION_OUTPUT_CAPABILITY,
15    GENERATION_BOUND_ACTIONS_CAPABILITY, MAX_FRAME_BYTES, PROTOCOL_MAJOR, PROTOCOL_MINOR,
16    TYPED_ACTION_RESULT_CAPABILITY,
17};
18pub use server::DaemonServer;
19
20/// Resolve the daemon socket without creating it.
21pub fn default_socket_path() -> PathBuf {
22    if let Some(path) = std::env::var_os("WINX_SOCKET") {
23        return PathBuf::from(path);
24    }
25    if let Some(runtime_dir) = std::env::var_os("XDG_RUNTIME_DIR") {
26        return PathBuf::from(runtime_dir).join("winx/winxd.sock");
27    }
28    PathBuf::from(format!("/tmp/winx-{}/winxd.sock", crate::os::unix::effective_uid()))
29}