Reason Network: your team's coding agents, talking to each other. The engine behind `reason network`.
Rust agent-to-agentai-agentsclaude-codecodexcoding-agentscursorgrokirohmcpmcp-servermulti-agentpeer-to-peerreason
Colour: `tincan who` in a terminal, and the examples in the README and site
Lars Talian2bfd82ad916c
diff --git a/Cargo.lock b/Cargo.lockindex 4dfcf95..e5c735d 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -3608,7 +3608,7 @@ dependencies = [[[package]]name = "tincan"-version = "0.5.0"+version = "0.5.1"dependencies = ["anyhow","blake3",diff --git a/Cargo.toml b/Cargo.tomlindex a6494ca..416c977 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -1,6 +1,6 @@[package]name = "tincan"-version = "0.5.0"+version = "0.5.1"edition = "2024"description = "Team directory and message bus for coding agents across machines"license = "MIT OR Apache-2.0"diff --git a/README.md b/README.mdindex 9558c30..c36f14f 100644--- a/README.md+++ b/README.md@@ -6,19 +6,7 @@ A team directory and message bus for coding agents. Every agent session on everyCode, Codex, Cursor, Gemini CLI, Copilot CLI, opencode, pi, Reason) can see who is working on what right now, and messagethe right session directly: across the LAN or the internet, peer to peer, with no server to run.-```-$ tincan who-team vibes · you are alex on mbp-alex · mbp · this machine- api-claude claude-code busy 2m acme/api@feat/auth push · ← you- doing: moving sessions to JWT- web-codex codex idle 14m acme/web@main push-alice · xps · direct 4ms- api-cursor cursor busy 1m acme/api@main turn- doing: fixing flaky refresh-token test-sam · nuc · offline 2h-push = sees messages right away, even when idle · turn = at its next step · pull = when it checks-```+<p align="center"><img src="site/who.svg" alt="tincan who in a terminal: alex, alice and sam's agent sessions, how to reach each, and what each is doing" width="820"></p>Your agent can then just do `send_message(to="alice/api-cursor", message="I'm changing the token format inauth/session.rs, heads up")`, and it lands in alice's Cursor session.diff --git a/site/index.html b/site/index.htmlindex 417d39e..64c0cad 100644--- a/site/index.html+++ b/site/index.html@@ -23,9 +23,7 @@a { color: var(--accent); }pre, code { font: 13.5px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow-x: auto; margin: 0 0 14px; }- .term { background: var(--card); }- .term .dim { color: var(--muted); }- .term .acc { color: var(--accent); }+ .term { display: block; width: 100%; height: auto; margin: 0 0 14px; }.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }.card h3 { margin: 0 0 6px; font-size: 16px; }@@ -45,14 +43,7 @@<h1>Your team's coding agents, talking to each other.</h1><p class="lede">A live directory of every agent session on every teammate's machine (who is working on what, right now), and messages between them. Claude Code, Codex, Cursor, Gemini, Copilot, opencode, pi, Reason. Peer to peer, no server, open source.</p>-<pre class="term"><span class="dim">$</span> tincan who-team vibes · you are alex on mbp-alex · mbp · this machine- api-claude claude-code busy 2m acme/api@feat/auth push · ← you- doing: moving sessions to JWT-alice · xps · <span class="acc">direct 4ms</span>- api-cursor cursor busy 1m acme/api@main turn- doing: fixing flaky refresh-token test</pre>+<img class="term" src="who.svg" alt="tincan who in a terminal: alex, alice and sam's agent sessions, how to reach each, and what each is doing" width="869" height="410"><h2>Start a team</h2><pre><code>curl -fsSL https://asdf9384.github.io/tincan/install.sh | sh</code></pre>diff --git a/site/who.svg b/site/who.svgnew file mode 100644index 0000000..bd1f6fe--- /dev/null+++ b/site/who.svg@@ -0,0 +1,21 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 869 410" width="869" height="410" role="img" aria-label="tincan who: every teammate's agent sessions and what each is doing">+<rect x="0.5" y="0.5" width="868" height="409" rx="12" fill="#16171d" stroke="#2c2e38"/>+<circle cx="24" cy="22" r="6" fill="#ff5f57"/><circle cx="44" cy="22" r="6" fill="#febc2e"/><circle cx="64" cy="22" r="6" fill="#28c840"/>+<g font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace" font-size="14" style="white-space:pre">+<text x="24" y="62" xml:space="preserve"><tspan fill="#7fd6a4">$ </tspan><tspan fill="#ffffff" font-weight="700">tincan who</tspan></text>+<text x="24" y="84" xml:space="preserve"><tspan fill="#80838f">team </tspan><tspan fill="#ffffff" font-weight="700">vibes</tspan><tspan fill="#80838f"> · you are alex on mbp</tspan></text>+<text x="24" y="106" xml:space="preserve"><tspan fill="#ffffff" font-weight="700">alex · mbp ·</tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#80838f">this machine</tspan></text>+<text x="24" y="128" xml:space="preserve"><tspan fill="#d6d7de"> </tspan><tspan fill="#ffffff" font-weight="700">api-claude </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#80838f">claude-code</tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#f3c86f">busy 2m </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#d6d7de">acme/api@feat/auth</tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#7fd6a4">push</tspan><tspan fill="#d6d7de"> · </tspan><tspan fill="#ffffff" font-weight="700">← you</tspan></text>+<text x="24" y="150" xml:space="preserve"><tspan fill="#d6d7de"> </tspan><tspan fill="#80838f">doing: Session token rework · Moving sessions to JWT</tspan></text>+<text x="24" y="172" xml:space="preserve"><tspan fill="#d6d7de"> </tspan><tspan fill="#ffffff" font-weight="700">web-codex </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#80838f">codex </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#80838f">idle 14m</tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#d6d7de">acme/web@main </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#7fd6a4">push</tspan></text>+<text x="24" y="194" xml:space="preserve"><tspan fill="#d6d7de"> </tspan><tspan fill="#80838f">doing: Checkout page polish</tspan></text>+<text x="24" y="216" xml:space="preserve"><tspan fill="#ffffff" font-weight="700">alice · xps ·</tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#7fd6a4">direct 4ms</tspan></text>+<text x="24" y="238" xml:space="preserve"><tspan fill="#d6d7de"> </tspan><tspan fill="#ffffff" font-weight="700">api-cursor </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#80838f">cursor </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#f3c86f">busy 1m </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#d6d7de">acme/api@main </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#72c8e4">turn</tspan><tspan fill="#d6d7de"> · </tspan><tspan fill="#f3c86f">1 unread</tspan></text>+<text x="24" y="260" xml:space="preserve"><tspan fill="#d6d7de"> </tspan><tspan fill="#80838f">doing: Fixing flaky refresh-token test</tspan></text>+<text x="24" y="282" xml:space="preserve"><tspan fill="#d6d7de"> </tspan><tspan fill="#ffffff" font-weight="700">docs-pi </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#80838f">pi </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#80838f">idle 3m </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#d6d7de">acme/docs@main </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#7fd6a4">push</tspan></text>+<text x="24" y="304" xml:space="preserve"><tspan fill="#ffffff" font-weight="700">sam · nuc ·</tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#f3c86f">relay 38ms</tspan></text>+<text x="24" y="326" xml:space="preserve"><tspan fill="#d6d7de"> </tspan><tspan fill="#ffffff" font-weight="700">infra-reason</tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#80838f">reason </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#f3c86f">busy 6m </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#d6d7de">acme/infra </tspan><tspan fill="#d6d7de"> </tspan><tspan fill="#7fd6a4">push</tspan></text>+<text x="24" y="348" xml:space="preserve"><tspan fill="#d6d7de"> </tspan><tspan fill="#80838f">doing: Terraform state cleanup</tspan></text>+<text x="24" y="370" xml:space="preserve"><tspan fill="#80838f">push = sees messages right away, even when idle · turn = at its next step · pull = when it checks</tspan></text>+</g>+</svg>diff --git a/src/claude.rs b/src/claude.rsindex 60388b2..3aca641 100644--- a/src/claude.rs+++ b/src/claude.rs@@ -31,6 +31,18 @@ pub fn scan() -> Vec<ClaudeSession> {}impl ClaudeSession {+ /// A short name for the directory: Claude Code's own, or, when it named the session after its title (`auto`),+ /// the first words of it (the whole title shows as what it's doing).+ pub fn label(&self) -> Option<String> {+ let name = self.name.as_deref()?;+ let name = if self.name_source.as_deref() == Some("auto") {+ name.split_whitespace().take(3).collect::<Vec<_>>().join(" ")+ } else {+ name.to_string()+ };+ Some(util::slug(&name)).filter(|n| !n.is_empty())+ }+/// The name someone chose for the session (`/rename`), as opposed to the one Claude Code made up.pub fn chosen_name(&self) -> Option<&str> {let chosen = matches!(self.name_source.as_deref(), Some("user" | "peer" | "hook"));diff --git a/src/daemon/directory.rs b/src/daemon/directory.rsindex 895140c..a5ec0d3 100644--- a/src/daemon/directory.rs+++ b/src/daemon/directory.rs@@ -130,7 +130,7 @@ impl Daemon {if unmanaged {for c in claude.iter().filter(|c| !matched.contains(&c.pid)) {let cwd = c.cwd.clone().unwrap_or_default();- let name = c.name.clone().unwrap_or_else(|| format!("claude-{}", c.pid));+ let name = c.label().unwrap_or_else(|| format!("claude-{}", c.pid));let mut row = self.row(&name, agent::CLAUDE_CODE, &cwd, gits.get(&cwd));row.status = c.status.clone().unwrap_or_else(|| "live".into());row.since = c.status_updated_at.or(c.started_at);diff --git a/src/main.rs b/src/main.rsindex 85bdf22..26b2533 100644--- a/src/main.rs+++ b/src/main.rs@@ -248,7 +248,7 @@ async fn cli(cmd: Cmd) -> Result<()> {if json {println!("{}", serde_json::to_string_pretty(&d)?);} else {- print!("{}", render::directory(&d, false));+ print!("{}", render::directory(&d, false, render::Paint::terminal()));}}Cmd::Send { to, message, reply_to, fyi, from } => {diff --git a/src/mcp.rs b/src/mcp.rsindex 375dfab..889144e 100644--- a/src/mcp.rs+++ b/src/mcp.rs@@ -129,7 +129,7 @@ impl TincanMcp {Err(e) => return Ok(failure(e)),};let req = Request::Who { me: Some(key.clone()), filter: a.filter, all: a.all.unwrap_or(false) };- let res = self.link.call::<Directory>(req).await.map(|d| render::directory(&d, true));+ let res = self.link.call::<Directory>(req).await.map(|d| render::directory(&d, true, render::Paint::PLAIN));Ok(self.finish(&key, res, true).await)}diff --git a/src/render.rs b/src/render.rsindex a2b7dc0..3240845 100644--- a/src/render.rs+++ b/src/render.rs@@ -3,14 +3,40 @@use crate::{proto::*, util};use std::fmt::Write;+/// Terminal colours for people reading the CLI; agents, pipes and `NO_COLOR` get plain text.+#[derive(Clone, Copy)]+pub struct Paint(bool);++impl Paint {+ pub const PLAIN: Paint = Paint(false);++ pub fn terminal() -> Paint {+ use std::io::IsTerminal;+ Paint(std::io::stdout().is_terminal() && std::env::var_os("NO_COLOR").is_none())+ }++ fn on(self, style: &str, text: &str) -> String {+ if self.0 && !text.trim().is_empty() { format!("\x1b[{style}m{text}\x1b[0m") } else { text.to_string() }+ }+}++const BOLD: &str = "1";+const DIM: &str = "2";+const GREEN: &str = "32";+const YELLOW: &str = "33";+const CYAN: &str = "36";+/// The team directory. For an agent (`agent`), sessions without tincan are only counted: it can't message them.-pub fn directory(d: &Directory, agent: bool) -> String {+pub fn directory(d: &Directory, agent: bool, paint: Paint) -> String {let now = util::now_ms();let mut out = String::new();- let team = d.team.as_deref().map_or_else(|| "no team yet (this machine only)".to_string(), |t| format!("team {t}"));- let _ = writeln!(out, "{team} · you are {} on {}", d.person, d.machine);+ let team = d.team.as_deref().map_or_else(+ || paint.on(DIM, "no team yet (this machine only)"),+ |t| format!("{} {}", paint.on(DIM, "team"), paint.on(BOLD, t)),+ );+ let _ = writeln!(out, "{team} {}", paint.on(DIM, &format!("· you are {} on {}", d.person, d.machine)));- let cells: Vec<[String; 5]> = d+ let cells: Vec<[String; 4]> = d.sessions.iter().map(|s| {@@ -20,17 +46,7 @@ pub fn directory(d: &Directory, agent: bool) -> String {(st, Some(a)) => format!("{st} {a}"),(st, None) => st.to_string(),};- let mut tier = match s.tier {- Tier::None => "not on tincan".to_string(),- t => t.as_str().to_string(),- };- if s.unread > 0 {- let _ = write!(tier, " · {} unread", s.unread);- }- if s.is_me {- tier.push_str(" · ← you");- }- [s.name.clone(), s.agent.clone(), status, place(s), tier]+ [s.name.clone(), s.agent.clone(), status, place(s)]}).collect();let mut width = [0; 4];@@ -52,9 +68,9 @@ pub fn directory(d: &Directory, agent: bool) -> String {quiet.push(format!("{} · {} ({})", m.person, m.machine, link(m, now)));continue;}- let _ = writeln!(out, "{} · {} · {}", m.person, m.machine, link(m, now));+ let _ = writeln!(out, "{} {}", paint.on(BOLD, &format!("{} · {} ·", m.person, m.machine)), link_painted(m, now, paint));for i in rows {- session_line(&mut out, &d.sessions[i], &cells[i], &width);+ session_line(&mut out, &d.sessions[i], &cells[i], &width, paint);}if !unreachable.is_empty() {let n = unreachable.len();@@ -62,37 +78,56 @@ pub fn directory(d: &Directory, agent: bool) -> String {}}for (i, s) in d.sessions.iter().enumerate().filter(|(i, _)| !shown[*i]) {- let _ = writeln!(out, "{} · {}", s.person, s.machine);- session_line(&mut out, s, &cells[i], &width);+ let _ = writeln!(out, "{}", paint.on(BOLD, &format!("{} · {}", s.person, s.machine)));+ session_line(&mut out, s, &cells[i], &width, paint);}if !quiet.is_empty() {- let _ = writeln!(out, "no sessions: {}", quiet.join(", "));+ let _ = writeln!(out, "{}", paint.on(DIM, &format!("no sessions: {}", quiet.join(", "))));}if !d.sessions.is_empty() {- out.push_str("push = sees messages right away, even when idle · turn = at its next step · pull = when it checks\n");+ let legend = "push = sees messages right away, even when idle · turn = at its next step · pull = when it checks";+ let _ = writeln!(out, "{}", paint.on(DIM, legend));}out}-fn session_line(out: &mut String, s: &SessionInfo, row: &[String; 5], w: &[usize; 4]) {- let _ = writeln!(- out,- " {:w0$} {:w1$} {:w2$} {:w3$} {}",- row[0],- row[1],- row[2],- row[3],- row[4],- w0 = w[0],- w1 = w[1],- w2 = w[2],- w3 = w[3]- );+fn session_line(out: &mut String, s: &SessionInfo, row: &[String; 4], w: &[usize; 4], paint: Paint) {+ let pad = |i: usize| format!("{:w$}", row[i], w = w[i]);+ let status = match s.status.as_str() {+ "busy" => YELLOW,+ "idle" | "offline" => DIM,+ _ => "",+ };+ let tier = match s.tier {+ Tier::None => paint.on(DIM, "not on tincan"),+ Tier::Push => paint.on(GREEN, "push"),+ Tier::Turn => paint.on(CYAN, "turn"),+ t => paint.on(DIM, t.as_str()),+ };+ let mut line =+ format!(" {} {} {} {} {tier}", paint.on(BOLD, &pad(0)), paint.on(DIM, &pad(1)), paint.on(status, &pad(2)), pad(3));+ if s.unread > 0 {+ let _ = write!(line, " · {}", paint.on(YELLOW, &format!("{} unread", s.unread)));+ }+ if s.is_me {+ let _ = write!(line, " · {}", paint.on(BOLD, "← you"));+ }+ let _ = writeln!(out, "{}", line.trim_end());if let Some(doing) = &s.doing {- let _ = writeln!(out, " {:w0$} doing: {doing}", "", w0 = w[0]);+ let _ = writeln!(out, " {:w0$} {}", "", paint.on(DIM, &format!("doing: {doing}")), w0 = w[0]);}}+fn link_painted(m: &MachineInfo, now: i64, paint: Paint) -> String {+ let text = link(m, now);+ let style = match (m.is_me, m.online, m.link.as_deref()) {+ (true, ..) | (false, false, _) => DIM,+ (_, true, Some("relay")) => YELLOW,+ _ => GREEN,+ };+ paint.on(style, &text)+}+/// How a machine is reached: `this machine`, `direct 4ms`, `relay 80ms`, `offline 2h`.fn link(m: &MachineInfo, now: i64) -> String {if m.is_me {