neural_conductor_shared/
lib.rs

1//! # Neural Conductor Shared
2//!
3//! Shared protocol and types for Neural Conductor.
4//!
5//! This crate provides the communication protocol between the Conductor server
6//! and remote agents. It defines message types, session management, and RPC interfaces.
7
8use serde::{Deserialize, Serialize};
9
10pub mod protocol;
11pub mod session;
12pub mod message;
13
14pub use anyhow::{anyhow, Result};
15
16/// Version of the protocol
17pub const PROTOCOL_VERSION: &str = "0.1.0";
18
19/// Agent identification
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct AgentInfo {
22    pub id: String,
23    pub hostname: String,
24    pub platform: String,
25    pub version: String,
26}
27
28/// Session identifier
29#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
30pub struct SessionId(pub String);
31
32impl SessionId {
33    pub fn new() -> Self {
34        // Simple UUID-like generation for now
35        Self(format!("session-{}", std::time::SystemTime::now()
36            .duration_since(std::time::UNIX_EPOCH)
37            .unwrap()
38            .as_millis()))
39    }
40}
41
42impl Default for SessionId {
43    fn default() -> Self {
44        Self::new()
45    }
46}
47
48/// Task status
49#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
50pub enum TaskStatus {
51    Pending,
52    Running,
53    Completed,
54    Failed,
55    Cancelled,
56}