Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

fix: the same answer to two requests reaches the bot that asked

leepokai76c23c2a650a
diff --git a/host/crates/network/src/node/inbound.rs b/host/crates/network/src/node/inbound.rs
index 8b77e3c6..f29de331 100644
--- a/host/crates/network/src/node/inbound.rs
+++ b/host/crates/network/src/node/inbound.rs
@@ -98,7 +98,8 @@ impl Inner {
}
let pair = format!("{peer}/{}>{}", envelope.from, envelope.to);
let meta = envelope.meta.as_ref().map(ToString::to_string).unwrap_or_default();
- let said = digest(&[&envelope.body, &meta]);
+ // Two answers to two different letters may well say the same thing ("Done.").
+ let said = digest(&[&envelope.body, &meta, envelope.reply_to.as_deref().unwrap_or_default()]);
if let Err(reason) = locked(&self.guard).admit(pair.clone(), envelope.hops, said, Instant::now()) {
return refuse(reason);
}
diff --git a/host/crates/network/tests/two_computers.rs b/host/crates/network/tests/two_computers.rs
index 953666ce..b96d234a 100644
--- a/host/crates/network/tests/two_computers.rs
+++ b/host/crates/network/tests/two_computers.rs
@@ -152,6 +152,26 @@ async fn letters_for_an_away_computer_wait() {
}
}
+#[tokio::test]
+async fn the_same_answer_to_two_letters_is_no_repeat() {
+ let (desk_dir, laptop_dir) = (temp_dir("desk3"), temp_dir("laptop3"));
+ let (desk, mut inbox) = Node::start(&desk_dir, &Connector::Private).await.unwrap();
+ desk.create("desk").unwrap();
+ offer(&desk, "lead");
+ let (laptop, _) = Node::start(&laptop_dir, &Connector::Private).await.unwrap();
+ offer(&laptop, "reviewer");
+ laptop.join(&desk.invite().unwrap(), "laptop").await.unwrap();
+ for request in ["a", "b"] {
+ laptop.send(Letter::new("reviewer", to("lead@desk"), "Done.").reply_to(request)).await.unwrap();
+ assert_eq!(next(&mut inbox).await.reply_to.as_deref(), Some(request));
+ }
+ let again = laptop.send(Letter::new("reviewer", to("lead@desk"), "Done.").reply_to("b")).await.unwrap_err();
+ assert!(again.to_string().contains("isn't delivered twice"), "{again}");
+ for dir in [desk_dir, laptop_dir] {
+ let _ = std::fs::remove_dir_all(dir);
+ }
+}
+
#[tokio::test]
async fn without_a_network_agents_on_one_computer_still_reach_each_other() {
let dir = temp_dir("alone");
diff --git a/host/src/chat/team.rs b/host/src/chat/team.rs
index ad7d3ca7..60aca9c6 100644
--- a/host/src/chat/team.rs
+++ b/host/src/chat/team.rs
@@ -294,8 +294,9 @@ pub fn call(hub: &Arc<Hub>, from: &str, name: &str, args: &Value) -> Result<Valu
"list_bots" => directory::list(hub, from, args, &[]),
"message_bot" => {
let to = args["botId"].as_str().ok_or_else(|| anyhow!("botId is required"))?;
- // A bot's address name works as well as its id.
- let to = hub.network.bot_for(to).unwrap_or_else(|| to.to_owned());
+ // A bot's address name works as well as its id, also as `name@` this computer.
+ let handle = to.rsplit_once('@').map_or(to, |(name, _)| name);
+ let to = hub.network.bot_for(handle).unwrap_or_else(|| to.to_owned());
let message = args["message"].as_str().unwrap_or_default().trim();
message_bot(hub, &source, &to, message)
}
diff --git a/host/src/network_cli.rs b/host/src/network_cli.rs
index e494ff2b..862ffa70 100644
--- a/host/src/network_cli.rs
+++ b/host/src/network_cli.rs
@@ -7,7 +7,8 @@ use serde_json::{Value, json};
#[derive(clap::Args)]
pub struct NetworkArgs {
- #[arg(long, default_value_t = crate::service::DEFAULT_PORT)]
+ /// The running host's port (also after the action).
+ #[arg(long, global = true, default_value_t = crate::service::DEFAULT_PORT)]
port: u16,
#[command(subcommand)]
action: Option<Action>,