liminal-server 0.24.9

Standalone server for the liminal messaging bus
Documentation
//! Agent stations use the console's existing activity contract.

use serde::Serialize;

use super::records::{AgentHarness, AgentRecord};
use crate::console::records::{Station, StationActivity, StationKind, StationState};

/// Agent metadata extends the shared station shape without changing other
/// station constructors or copying a working stream out of Lys.
#[derive(Clone, Serialize)]
pub struct AgentStation {
    /// The shared station fields.
    #[serde(flatten)]
    pub station: Station,
    /// The profile's harness label.
    pub harness: AgentHarness,
    /// The approved sentence stating the station's job.
    pub purpose: String,
    /// Subjects the live ticket listens to, in subject order.
    pub stops: Vec<String>,
}

impl AgentStation {
    /// The inbox is one activity accepting text as data.
    #[must_use]
    pub fn new(
        record: &AgentRecord,
        device: &str,
        state: StationState,
        stops: Vec<String>,
    ) -> Self {
        let inbox = format!("agents.{}.inbox", record.name);
        Self { station: Station { id: inbox.clone(), name: record.name.clone(), device: device.into(),
            kind: StationKind::Agent, state, subjects: Some(vec![inbox]), activities: Some(vec![StationActivity {
                name: "inbox".into(),
                input_schema_json: r#"{"additionalProperties":false,"properties":{"text":{"type":"string"}},"required":["text"],"type":"object"}"#.into(),
                output_schema_json: "{}".into(),
            }]) }, harness: record.harness, purpose: record.purpose.clone(), stops }
    }
}

impl std::fmt::Debug for AgentStation {
    fn fmt(&self, out: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        out.debug_struct("AgentStation")
            .field("harness", &self.harness)
            .finish_non_exhaustive()
    }
}