diff --git a/Cargo.toml b/Cargo.toml index b04ffd1..253cb19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["channels/irc", "channels/telegram"] +members = ["channels/irc", "channels/telegram", "channels/tmux"] resolver = "2" [workspace.package] diff --git a/channels/tmux/Cargo.toml b/channels/tmux/Cargo.toml new file mode 100644 index 0000000..28baea5 --- /dev/null +++ b/channels/tmux/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "consciousness-channel-tmux" +version.workspace = true +edition.workspace = true + +[dependencies] +capnp = "0.20" +capnp-rpc = "0.20" +dirs = "6" +libc = "0.2" +scopeguard = "1" +futures = "0.3" +json5 = "0.4" +poc-memory = { path = "../.." } +serde = { version = "1", features = ["derive"] } +tokio = { version = "1", features = ["full"] } +tokio-util = { version = "0.7", features = ["compat"] } +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/channels/tmux/src/main.rs b/channels/tmux/src/main.rs new file mode 100644 index 0000000..b3e3711 --- /dev/null +++ b/channels/tmux/src/main.rs @@ -0,0 +1,305 @@ +// channel-tmux — Tmux pane channel daemon +// +// Uses tmux pipe-pane to stream pane output directly — no polling. +// Each configured pane gets a Unix socket pair; pipe-pane sends +// output to one end, the daemon reads from the other and pushes +// new lines into ChannelLogs. +// +// Config: ~/.consciousness/channels/tmux.json5 +// Socket: ~/.consciousness/channels/tmux.sock + +use std::cell::RefCell; +use std::collections::BTreeMap; +use std::rc::Rc; + +use capnp::capability::Promise; +use capnp_rpc::{pry, rpc_twoparty_capnp, twoparty, RpcSystem}; +use futures::AsyncReadExt; +use tokio::io::AsyncBufReadExt; +use tokio::net::UnixListener; +use tokio_util::compat::TokioAsyncReadCompatExt; +use tracing::{error, info, warn}; + +use poc_memory::channel_capnp::{channel_client, channel_server}; +use poc_memory::thalamus::channel_log::ChannelLog; + +// ── Config ───────────────────────────────────────────────────── + +#[derive(Clone, serde::Deserialize)] +struct PaneConfig { + /// Tmux pane ID, e.g. "0:1.0" + pane_id: String, + /// Human-readable label, becomes the channel name "tmux.