Skip to main content

oxios_cli/
plugin.rs

1//! CLI channel plugin.
2//!
3//! Factory for creating the CLI channel. Implements
4//! [`ChannelPlugin`](oxios_gateway::plugin::ChannelPlugin) so the
5//! main binary can activate the CLI channel from configuration.
6//!
7//! Note: The interactive readline loop is *not* started here — that
8//! is only used by the `oxios chat` subcommand.
9
10use anyhow::Result;
11use async_trait::async_trait;
12use oxios_gateway::plugin::{ChannelBundle, ChannelContext, ChannelPlugin};
13
14use crate::channel::CliChannel;
15
16/// CLI channel plugin — creates a stdin/stdout channel.
17pub struct CliPlugin;
18
19impl CliPlugin {
20    /// Create a new CLI plugin instance.
21    pub fn new() -> Self {
22        Self
23    }
24}
25
26impl Default for CliPlugin {
27    fn default() -> Self {
28        Self::new()
29    }
30}
31
32#[async_trait]
33impl ChannelPlugin for CliPlugin {
34    fn name(&self) -> &str {
35        "cli"
36    }
37
38    async fn setup(&self, _ctx: ChannelContext) -> Result<ChannelBundle> {
39        let channel = CliChannel::new(256);
40        Ok(ChannelBundle {
41            channel: Box::new(channel),
42            tasks: vec![],
43        })
44    }
45}