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
Merge #9: notify, when a message needs the person
Lars Talian2d50f28ca7c1
diff --cc README.mdindex bae4a84,3ddb6ce..237ee84--- a/README.md+++ b/README.md@@@ -43,7 -46,7 +46,8 @@@ That's it. Ask any agent "who's on the```shtincan who # who's around and what their sessions are doingtincan send alice/api-claude "did the token format change?" # message one of alice's agents+tincan send '*' "deploying api at 5" # everyone (also alice/* or repo:api): from you at a terminal, never an agent+ tincan send alice/api-claude --notify "approve the deploy?" # and pop it up on alice's screentincan listen --as terminal # replies to what you sent from this terminaltincan link # the team link againtincan setup # which agents are on tincan, and how messages are handleddiff --cc site/index.htmlindex f805f7c,34c3cf6..9f333c1--- a/site/index.html+++ b/site/index.html@@@ -190,8 -190,8 +190,9 @@@<dt>sven/*</dt><dd>all of sven's sessions</dd><dt>repo:api</dt><dd>every session working in that repo</dd><dt>*</dt><dd>everyone (rarely a good idea)</dd>+ <dt>you</dt><dd>with notify: a pop-up on your own screen, from an agent that needs you</dd></dl>+ <p class="muted">Groups are for a person at a terminal; agents always message one session.</p></section><section class="sec">diff --cc site/skill/SKILL.mdindex 6569e38,3b729ca..5633c0d--- a/site/skill/SKILL.md+++ b/site/skill/SKILL.md@@@ -26,8 -26,10 +26,9 @@@ powershell -c "& ([scriptblock]::Create## Commands- `tincan who`: every person, machine and session, with what each is working on.-- `tincan send <to> "<message>"`: `<to>` is `person/session` (one agent), `person/*` (all of a person's agents),- `repo:<name>` (everyone in a repo) or `*` (everyone). Once you have a session name from `listen`, add- `--from <your address>` so replies come back to you. `--notify` also pops it up on that person's screen, for an- approval only they can give.+- `tincan send <to> "<message>"`: `<to>` is one agent session, `person/session`. Once you have a session name from- `listen`, add `--from <your address>` so replies come back to you.++ `listen`, add `--from <your address>` so replies come back to you. `--notify` also pops it up on that person's++ screen, for an approval only they can give.- `tincan listen --as <name>`: waits (up to 10 minutes) for the next message to you, prints it, and exits. Youare reachable as `<your user>/<name>`. After handling a message and replying, run it again to keep listening.diff --cc src/daemon/mail.rsindex 778b0f4,e4bfed0..8036413--- a/src/daemon/mail.rs+++ b/src/daemon/mail.rs@@@ -109,11 -113,42 +113,46 @@@ impl Daemonlet (from_addr, from_agent, from_repo) =(self.addr(&sender.name), Some(sender.reg.agent.clone()), sender.git.repo.clone());let exclude = sender.reg.key.clone();+ // A person at a terminal may message a group; an agent picks the one session it needs.+ if is_group(to) && !from_addr.ends_with("/terminal") {+ bail!("agents message one session, not a group: pick it with list_team, or ask your user");+ }- let targets = self.resolve(&g, &remotes, to, Some(&exclude))?;+ // Your own user, not a session: just the pop-up, on each of their machines that is on now. (To get a+ // teammate's attention, message one of their sessions with notify.)+ let own = notify && to == self.person;+ if own {+ let msg = Message {+ id: Ulid::new().to_string(),+ from: from_addr.clone(),+ from_agent: from_agent.clone(),+ from_repo: from_repo.clone(),+ to: to.to_string(),+ via: None,+ reply_to: reply_to.clone(),+ body: body.to_string(),+ wake: false,+ notify: true,+ sent_at: now,+ };+ let (sent, note) = self.notify(&msg);+ let state = if sent { "notified" } else { "not notified" };+ res.recipients.push(Recipient { address: format!("{to}@{}", self.machine), state: state.into(), note });+ for m in g.team.iter().flat_map(|t| t.active()).filter(|m| m.person == to) {+ // Machines we've never heard from (and this one) aren't in `remotes`.+ let Some(online) = remotes.get(&m.endpoint).map(|r| r.online) else { continue };+ let address = format!("{to}@{}", m.machine);+ let note = if online {+ format!("no answer from {}", m.machine)+ } else {+ format!("{} is offline", m.machine)+ };+ if online {+ remote_jobs.push((res.recipients.len(), m.endpoint, m.machine.clone(), true, msg.clone()));+ }+ res.recipients.push(Recipient { address, state: "not notified".into(), note });+ }+ }+ let targets = if own { Vec::new() } else { self.resolve(&g, &remotes, to, Some(&exclude))? };for t in targets {let msg = Message {id: Ulid::new().to_string(),@@@ -406,15 -459,9 +463,15 @@@if !g.loop_ok(&msg.from, &msg.to) {return Ok(("refused".into(), LOOP_NOTE.into()));}+ // Only an older tincan still sends an agent's group message; a teammate's isn't taken.+ let sender = msg.from.split_once('/').map_or(msg.from.as_str(), |(p, _)| p);+ if msg.via.is_some() && !msg.from.ends_with("/terminal") && sender != self.person {+ let note = format!("refused: agents message one of {}'s sessions, not a group", self.person);+ return Ok(("refused".into(), note));+ }let held = policy == Policy::Hold;g.store.insert(&msg, held)?;- match key {+ let (state, note) = match key {_ if held => ("held".into(), format!("held until {} approves it", self.person)),Some(key) => self.deliver(&mut g, &key, vec![msg.clone()], msg.wake),None => ("queued".into(), "queued: the session is offline; delivered when it is back".into()),diff --cc src/main.rsindex 23e3359,4696899..71eb3a5--- a/src/main.rs+++ b/src/main.rs@@@ -316,14 -319,8 +319,15 @@@ async fn cli(cmd: Cmd) -> Result<()>body: body.clone(),reply_to: reply_to.clone(),wake: !fyi,+ notify,};+ // As the terminal, a group send has to come from a person sitting at it, not an agent's shell or a script.+ let as_terminal = || {+ if is_group(&to) && !std::io::IsTerminal::is_terminal(&std::io::stderr()) {+ bail!("only a person at a terminal sends to a group; from a script, add `--from <you>/terminal`");+ }+ Ok(())+ };let explicit = from.is_some();let r: SendResult = match from.or_else(current_session) {Some(f) => match link.call(send(f)).await {