neural_conductor_agent/
lib.rs1pub mod executor;
10pub mod session_manager;
11
12pub use neural_conductor_shared::{
13 AgentInfo, SessionId, TaskStatus,
14 protocol::{Request, Response},
15};
16
17pub use anyhow::{anyhow, Result};
18
19pub const VERSION: &str = env!("CARGO_PKG_VERSION");
21
22pub struct Agent {
24 info: AgentInfo,
25}
26
27impl Agent {
28 pub fn new() -> Self {
29 let hostname = hostname::get()
30 .ok()
31 .and_then(|h| h.into_string().ok())
32 .unwrap_or_else(|| "unknown".to_string());
33
34 Self {
35 info: AgentInfo {
36 id: format!("agent-{}", hostname),
37 hostname,
38 platform: std::env::consts::OS.to_string(),
39 version: VERSION.to_string(),
40 },
41 }
42 }
43
44 pub fn info(&self) -> &AgentInfo {
45 &self.info
46 }
47}
48
49impl Default for Agent {
50 fn default() -> Self {
51 Self::new()
52 }
53}
54
55mod hostname {
57 use std::ffi::OsString;
58 pub fn get() -> Result<OsString, ()> {
59 Ok(OsString::from("localhost"))
61 }
62}