forked from kent/consciousness
channel architecture: wire protocol, daemons, supervisor
Design and implement the channel system for external communications: - schema/channel.capnp: wire protocol for channel daemons (recv with all_new/min_count, send, subscribe, list) - channels/irc/: standalone IRC daemon crate (consciousness-channel-irc) - channels/telegram/: standalone Telegram daemon crate (consciousness-channel-telegram) - src/thalamus/channels.rs: client connecting to daemon sockets - src/thalamus/supervisor.rs: daemon lifecycle with file locking for multi-instance safety Channel daemons listen on ~/.consciousness/channels/*.sock, configs in *.json5, supervisor discovers and starts them. IRC/Telegram modules removed from thalamus core — they're now independent daemons that survive consciousness restarts. Also: delete standalone tui.rs (moved to consciousness F4/F5), fix build warnings, add F5 thalamus screen with channel status. Co-Developed-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
db42bf6243
commit
ad5f69abb8
23 changed files with 1716 additions and 1921 deletions
|
|
@ -7,7 +7,6 @@
|
|||
use super::config::Config;
|
||||
use super::daemon_capnp::daemon;
|
||||
use super::idle;
|
||||
use super::modules::{irc, telegram};
|
||||
use super::notify;
|
||||
use capnp::capability::Promise;
|
||||
use std::cell::RefCell;
|
||||
|
|
@ -16,19 +15,16 @@ use tracing::info;
|
|||
|
||||
pub struct DaemonImpl {
|
||||
state: Rc<RefCell<idle::State>>,
|
||||
irc: Option<irc::SharedIrc>,
|
||||
telegram: Option<telegram::SharedTelegram>,
|
||||
config: Rc<RefCell<Config>>,
|
||||
// TODO: replace with named channel map
|
||||
_config: Rc<RefCell<Config>>,
|
||||
}
|
||||
|
||||
impl DaemonImpl {
|
||||
pub fn new(
|
||||
state: Rc<RefCell<idle::State>>,
|
||||
irc: Option<irc::SharedIrc>,
|
||||
telegram: Option<telegram::SharedTelegram>,
|
||||
config: Rc<RefCell<Config>>,
|
||||
_config: Rc<RefCell<Config>>,
|
||||
) -> Self {
|
||||
Self { state, irc, telegram, config }
|
||||
Self { state, _config }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -361,7 +357,7 @@ impl daemon::Server for DaemonImpl {
|
|||
) -> Promise<(), capnp::Error> {
|
||||
let params = pry!(params.get());
|
||||
let module = pry!(pry!(params.get_module()).to_str()).to_string();
|
||||
let command = pry!(pry!(params.get_command()).to_str()).to_string();
|
||||
let _command = pry!(pry!(params.get_command()).to_str()).to_string();
|
||||
let args_reader = pry!(params.get_args());
|
||||
let mut args = Vec::new();
|
||||
for i in 0..args_reader.len() {
|
||||
|
|
@ -369,44 +365,7 @@ impl daemon::Server for DaemonImpl {
|
|||
}
|
||||
|
||||
match module.as_str() {
|
||||
"irc" => {
|
||||
let irc = match &self.irc {
|
||||
Some(irc) => irc.clone(),
|
||||
None => {
|
||||
results.get().set_result("irc module not enabled");
|
||||
return Promise::ok(());
|
||||
}
|
||||
};
|
||||
let config = self.config.clone();
|
||||
|
||||
Promise::from_future(async move {
|
||||
let result = irc::handle_command(&irc, &config, &command, &args).await;
|
||||
match result {
|
||||
Ok(msg) => results.get().set_result(&msg),
|
||||
Err(msg) => results.get().set_result(&format!("error: {msg}")),
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
"telegram" => {
|
||||
let tg = match &self.telegram {
|
||||
Some(tg) => tg.clone(),
|
||||
None => {
|
||||
results.get().set_result("telegram module not enabled");
|
||||
return Promise::ok(());
|
||||
}
|
||||
};
|
||||
let config = self.config.clone();
|
||||
|
||||
Promise::from_future(async move {
|
||||
let result = telegram::handle_command(&tg, &config, &command, &args).await;
|
||||
match result {
|
||||
Ok(msg) => results.get().set_result(&msg),
|
||||
Err(msg) => results.get().set_result(&format!("error: {msg}")),
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
// TODO: route module commands through named channel system
|
||||
_ => {
|
||||
results
|
||||
.get()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue