aidaemon-nodes 0.24.0

Nodes for aidaemon agents: enrolled hardware companions with server-issued identity, their HTTP Gateway, store, OTA releases, speech, monitoring and the tools that read and command them; implementation crate of the aidaemon SDK, no stability promise (use it through aidaemon-sdk)
use std::sync::Arc;

use async_trait::async_trait;

use aidaemon_channels::hub::{ChannelCapabilities, HubChannel, MediaMessage};
use aidaemon_tools::command_risk::{PermissionMode, RiskLevel};
use aidaemon_tools::semantics::ApprovalResponse;

use super::domain::NODE_CHANNEL_NAME;
use super::store::NodeStore;

pub struct NodeChannel {
    store: Arc<NodeStore>,
}

impl NodeChannel {
    pub fn new(store: Arc<NodeStore>) -> Self {
        Self { store }
    }
}

#[async_trait]
impl HubChannel for NodeChannel {
    fn name(&self) -> String {
        NODE_CHANNEL_NAME.to_string()
    }
    fn capabilities(&self) -> ChannelCapabilities {
        ChannelCapabilities {
            markdown: false,
            inline_buttons: false,
            media: false,
            max_message_len: 4096,
        }
    }
    async fn send_text(&self, session_id: &str, text: &str) -> anyhow::Result<()> {
        self.store
            .append_outbound_for_conversation(session_id, text)
            .await?;
        Ok(())
    }
    async fn send_media(&self, _session_id: &str, _media: &MediaMessage) -> anyhow::Result<()> {
        anyhow::bail!("Node media delivery is not enabled")
    }
    async fn request_approval(
        &self,
        _session_id: &str,
        _command: &str,
        _risk_level: RiskLevel,
        _warnings: &[String],
        _permission_mode: PermissionMode,
        _one_time_only: bool,
    ) -> anyhow::Result<ApprovalResponse> {
        Ok(ApprovalResponse::Deny)
    }
    async fn request_goal_confirmation(
        &self,
        _session_id: &str,
        _goal_description: &str,
        _details: &[String],
        _style: aidaemon_tools::semantics::GoalConfirmationStyle,
    ) -> anyhow::Result<bool> {
        Ok(false)
    }
}