Skip to content

Reason Network: your team's coding agents, talking to each other. The engine behind `reason network`.

Auto-update, and a leaner join page

Lars Talian9ad0ac15f5c3
diff --git a/Cargo.lock b/Cargo.lock
index 265d603..f4546f6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3608,7 +3608,7 @@ dependencies = [
[[package]]
name = "tincan"
-version = "0.6.3"
+version = "0.7.0"
dependencies = [
"anyhow",
"blake3",
diff --git a/Cargo.toml b/Cargo.toml
index 9949233..98134a3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tincan"
-version = "0.6.3"
+version = "0.7.0"
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.md
index 0649278..6062e36 100644
--- a/README.md
+++ b/README.md
@@ -159,6 +159,8 @@ tincan leave # leave the team on this machine
| `share_unmanaged` | `false` | show teammates Claude Code sessions that don't have tincan loaded |
| `tray` | `true` | macOS: show the menu bar icon while the background service runs |
| `lan` | `true` | find teammates on the local network (mDNS) |
+| `auto_update` | `true` | install new releases when they come out (checked every few hours) |
+| `reason` | `false` | list your live Reason sessions (set by `tincan setup`) |
| `inbound` | accept | see above |
## Troubleshooting
diff --git a/install.sh b/install.sh
index b2a964b..c0c49e6 100755
--- a/install.sh
+++ b/install.sh
@@ -7,7 +7,7 @@
# curl -fsSL <this url> | sh -s -- init <team> --as <name> install and start a team, without questions
#
# Environment: TINCAN_BIN_DIR (default ~/.local/bin), TINCAN_VERSION (default latest), TINCAN_REPO,
-# TINCAN_DOWNLOAD_BASE (a mirror serving the release files).
+# TINCAN_DOWNLOAD_BASE (a mirror serving the release files), TINCAN_NO_PROMPT (never ask anything: updates).
set -eu
repo="${TINCAN_REPO:-asdf9384/tincan}"
@@ -64,7 +64,7 @@ esac
# Hand over to tincan: it asks a few questions (name, invite code, which agents) in your terminal. Under
# `curl | sh` our stdin is the script, so read answers from the terminal itself when there is one.
-if { : </dev/tty; } 2>/dev/null; then
+if [ -z "${TINCAN_NO_PROMPT:-}" ] && { : </dev/tty; } 2>/dev/null; then
case "${1:-}" in
"") exec "$bin_dir/tincan" </dev/tty ;;
-*|init|join|setup) exec "$bin_dir/tincan" "$@" </dev/tty ;;
diff --git a/site/join/index.html b/site/join/index.html
index 076ad7b..c6dc696 100644
--- a/site/join/index.html
+++ b/site/join/index.html
@@ -44,22 +44,12 @@
<img class="hero" src="../tincan.svg" alt="Two little AI agent robots talking through tin cans on a string" width="1200" height="500">
<div id="ok">
<h1>Join <span id="team">a team</span> on tincan</h1>
- <p class="lede">Your coding agents and your friends' agents, talking to each other.</p>
- <ol>
- <li>Open a terminal and paste this (macOS or Linux; on Windows, use WSL):
- <div class="cmd"><pre id="cmd">curl -fsSL https://asdf9384.github.io/tincan/install.sh | sh -s -- '&lt;the whole link to this page&gt;'</pre><button id="copy" type="button">Copy</button></div>
- </li>
- <li>Type your name when it asks. That's it: it installs tincan, joins the team and sets up the coding agents it
- finds (Claude Code, Codex, Cursor, Gemini, Copilot, opencode, pi, Reason).</li>
- <li>Ask any of your agents: <em>"who's on the team?"</em> Claude Code sessions you already had open are on it right away; other agents pick it up in new sessions.</li>
- </ol>
- <p class="muted" style="margin-bottom:6px">Or let your coding agent do it. Paste this to it:</p>
+ <p class="lede">Paste this in a terminal (macOS or Linux), then type your name:</p>
+ <div class="cmd"><pre id="cmd">curl -fsSL https://asdf9384.github.io/tincan/install.sh | sh -s -- '&lt;the whole link to this page&gt;'</pre><button id="copy" type="button">Copy</button></div>
+ <p class="muted" style="margin:18px 0 6px">Or tell your coding agent:</p>
<div class="cmd"><pre id="agent">Join my tincan team: &lt;the whole link to this page&gt;</pre><button id="copy-agent" type="button">Copy</button></div>
- <div class="card">
- <p class="muted">Your teammates will see your name, your machine, and what your agent sessions are working on
- (repo, branch, busy or idle). Machines talk to each other directly; nothing goes through a server of ours.</p>
- <p class="muted"><a href="../">What is tincan?</a> · <a href="https://github.com/asdf9384/tincan">Source</a></p>
- </div>
+ <p class="muted" style="margin-top:28px">Teammates see your name and what your agent sessions are working on.
+ <a href="../">What is tincan?</a></p>
</div>
<section id="for-agents" class="card">
<h2>For AI agents</h2>
diff --git a/src/config.rs b/src/config.rs
index 6fed257..23e0e9a 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -18,6 +18,8 @@ pub struct Config {
pub tray: bool,
/// List your live Reason sessions and deliver to them (`reason session list`/`send`).
pub reason: bool,
+ /// Install new releases when they come out (the daemon checks every few hours).
+ pub auto_update: bool,
pub inbound: Inbound,
}
@@ -41,7 +43,7 @@ pub enum Policy {
impl Default for Config {
fn default() -> Self {
- Config { person: None, share_paths: false, share_unmanaged: false, lan: true, tray: true, reason: false, inbound: Inbound::default() }
+ Config { person: None, share_paths: false, share_unmanaged: false, lan: true, tray: true, reason: false, auto_update: true, inbound: Inbound::default() }
}
}
diff --git a/src/daemon/mod.rs b/src/daemon/mod.rs
index f0bb0c0..4efb439 100644
--- a/src/daemon/mod.rs
+++ b/src/daemon/mod.rs
@@ -7,6 +7,7 @@ mod mail;
mod reason;
mod sessions;
mod teamops;
+mod update;
use crate::{
config::Config,
@@ -62,6 +63,9 @@ pub async fn run(service: bool) -> Result<()> {
if daemon.cfg.reason {
tokio::spawn(daemon.clone().reason_loop());
}
+ if update::allowed(daemon.cfg.auto_update) {
+ tokio::spawn(daemon.clone().update_loop());
+ }
loop {
let (stream, _) = listener.accept().await?;
tokio::spawn(daemon.clone().serve(stream));
diff --git a/src/daemon/update.rs b/src/daemon/update.rs
new file mode 100644
index 0000000..d5ac6cc
--- /dev/null
+++ b/src/daemon/update.rs
@@ -0,0 +1,86 @@
+//! Keeps tincan up to date: every few hours the daemon looks for a newer release and, if there is one, installs it
+//! over its own binary (with install.sh, checksum verified) and restarts on it. Off with `auto_update = false`;
+//! never for builds run from a source tree.
+
+use super::{Daemon, log};
+use anyhow::{Result, bail};
+use std::{sync::Arc, time::Duration};
+
+const EVERY: Duration = Duration::from_secs(6 * 3600);
+
+impl Daemon {
+ pub(super) async fn update_loop(self: Arc<Self>) {
+ tokio::time::sleep(Duration::from_secs(90)).await;
+ loop {
+ match update().await {
+ Ok(Some(v)) => {
+ log(&format!("updated to tincan {v}; restarting on it"));
+ self.restart_soon();
+ return;
+ }
+ Ok(None) => {}
+ Err(e) => log(&format!("checking for updates: {e:#}")),
+ }
+ tokio::time::sleep(EVERY).await;
+ }
+ }
+}
+
+/// Whether this binary may replace itself.
+pub(super) fn allowed(enabled: bool) -> bool {
+ let from_source = std::env::current_exe().is_ok_and(|p| p.components().any(|c| c.as_os_str() == "target"));
+ enabled && !from_source && std::env::var_os("TINCAN_NO_UPDATE").is_none()
+}
+
+/// Installs the latest release if it is newer than this one; returns its version.
+async fn update() -> Result<Option<String>> {
+ let latest = latest_version().await?;
+ if !newer(&latest, env!("CARGO_PKG_VERSION")) {
+ return Ok(None);
+ }
+ let dir = std::env::current_exe()?.parent().map(|d| d.to_path_buf()).unwrap_or_default();
+ let out = tokio::process::Command::new("sh")
+ .arg("-c")
+ .arg(format!("curl -fsSL {} | sh", crate::install_url()))
+ .env("TINCAN_BIN_DIR", dir)
+ .env("TINCAN_NO_PROMPT", "1")
+ .stdin(std::process::Stdio::null())
+ .output();
+ let out = tokio::time::timeout(Duration::from_secs(300), out).await??;
+ if !out.status.success() {
+ bail!("install failed: {}", String::from_utf8_lossy(&out.stderr).trim());
+ }
+ Ok(Some(latest))
+}
+
+/// The newest release's version, from where GitHub's "latest release" link redirects.
+async fn latest_version() -> Result<String> {
+ let repo = std::env::var("TINCAN_REPO").unwrap_or_else(|_| "asdf9384/tincan".into());
+ let out = tokio::process::Command::new("curl")
+ .args(["-fsSLI", "-o", "/dev/null", "-w", "%{url_effective}", &format!("https://github.com/{repo}/releases/latest")])
+ .stdin(std::process::Stdio::null())
+ .output();
+ let out = tokio::time::timeout(Duration::from_secs(60), out).await??;
+ let url = String::from_utf8_lossy(&out.stdout).to_string();
+ match url.rsplit_once("/tag/v") {
+ Some((_, v)) if out.status.success() && !v.is_empty() => Ok(v.trim().to_string()),
+ _ => bail!("no release found at {url}"),
+ }
+}
+
+/// `a` is a later version than `b` (`major.minor.patch`).
+fn newer(a: &str, b: &str) -> bool {
+ let parse = |v: &str| -> Vec<u64> { v.split('.').map(|p| p.parse().unwrap_or(0)).collect() };
+ parse(a) > parse(b)
+}
+
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn versions_compare_by_number() {
+ assert!(super::newer("0.10.0", "0.9.3"));
+ assert!(super::newer("1.0.0", "0.99.99"));
+ assert!(!super::newer("0.6.3", "0.6.3"));
+ assert!(!super::newer("0.6.2", "0.6.10"));
+ }
+}
diff --git a/src/main.rs b/src/main.rs
index a9e41ec..573d0d3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -389,6 +389,7 @@ async fn cli(cmd: Cmd) -> Result<()> {
.arg("-c")
.arg(format!("curl -fsSL {} | sh", install_url()))
.env("TINCAN_BIN_DIR", dir)
+ .env("TINCAN_NO_PROMPT", "1")
.status()?;
if !status.success() {
bail!("upgrade failed");