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(network): address names in any script fit the bounds

leepokai75f586bb590b
diff --git a/docs/features/codync-network.md b/docs/features/codync-network.md
index 7c703a8f..7972f4a2 100644
--- a/docs/features/codync-network.md
+++ b/docs/features/codync-network.md
@@ -142,7 +142,7 @@ that was off learns of a removal.
reaches its request even when the asking bot was renamed or hidden meanwhile. The chain's hop limit counts
across computers (replies carry it back, one more handoff each), and the receiving computer enforces its own budgets:
8 handoffs per chain, a burst of 5 messages per pair of agents then one every 2 minutes, the same words twice in
- 10 minutes refused. A letter's id is at most 64 bytes, its addresses 128, its body 64 KiB; what another computer
+ 10 minutes refused. A letter's id is at most 64 bytes, its addresses 256 (40 characters of any script), its body 64 KiB; what another computer
offers is kept to its first 200 agents, names cut to 80 bytes and descriptions to 1 KiB. A letter that isn't a
request (a notice, or a reply nobody waits for after a restart) shows as a "Note from …" notice in the bot's chat.
- Agents on this computer that aren't Codync bots (a Claude Code or Codex session) get `list_bots`, `message_bot`
diff --git a/host/crates/network/src/bin/codync-network/main.rs b/host/crates/network/src/bin/codync-network/main.rs
index 376156d7..e80693a9 100644
--- a/host/crates/network/src/bin/codync-network/main.rs
+++ b/host/crates/network/src/bin/codync-network/main.rs
@@ -238,8 +238,11 @@ impl Daemon {
}
fn add(&self, local: LocalAgent) -> Result<String> {
- if local.agent.id == TERMINAL || local.agent.id.contains(['/', ' ']) || local.agent.id.len() > 64 {
- bail!("pick another agent name (not {TERMINAL}, at most 64 characters, no spaces or /)");
+ if local.agent.id == TERMINAL
+ || local.agent.id.contains(['/', ' '])
+ || local.agent.id.len() > codync_network::MAX_ADDRESS
+ {
+ bail!("pick another agent name (not {TERMINAL}, shorter, no spaces or /)");
}
let id = local.agent.id.clone();
let mut agents = self.agents.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
diff --git a/host/crates/network/src/lib.rs b/host/crates/network/src/lib.rs
index 62e46cf8..5b7f5df2 100644
--- a/host/crates/network/src/lib.rs
+++ b/host/crates/network/src/lib.rs
@@ -31,4 +31,4 @@ pub use reach::Reach;
pub use roster::Role;
pub use rules::{Access, Rule};
pub use types::{Address, Connector, Letter, Message, Peer, Sent};
-pub use wire::{Agent, AgentKind, InviteInfo, MAX_BODY, read_invite};
+pub use wire::{Agent, AgentKind, InviteInfo, MAX_ADDRESS, MAX_BODY, read_invite};
diff --git a/host/crates/network/src/node/directory.rs b/host/crates/network/src/node/directory.rs
index 7b0e3ec8..d86db9fb 100644
--- a/host/crates/network/src/node/directory.rs
+++ b/host/crates/network/src/node/directory.rs
@@ -23,7 +23,7 @@ const MAX_AGENT_NAME: usize = 80;
const MAX_ABOUT: usize = 1024;
/// Another computer's agents within bounds: the first [`MAX_AGENTS`] with an id a letter can
-/// carry, their names and descriptions cut to length.
+/// carry ([`wire::MAX_ADDRESS`](crate::wire::MAX_ADDRESS)), their names and descriptions cut to length.
fn bounded(agents: Vec<Agent>) -> Vec<Agent> {
let cut = |text: &mut String, max: usize| {
if text.len() > max {
@@ -33,7 +33,7 @@ fn bounded(agents: Vec<Agent>) -> Vec<Agent> {
};
agents
.into_iter()
- .filter(|a| !a.id.is_empty() && a.id.len() <= crate::wire::MAX_ID)
+ .filter(|a| !a.id.is_empty() && a.id.len() <= crate::wire::MAX_ADDRESS)
.take(MAX_AGENTS)
.map(|mut a| {
cut(&mut a.name, MAX_AGENT_NAME);
@@ -130,12 +130,15 @@ mod tests {
#[test]
fn another_computers_offer_is_cut_to_bounds() {
let agent = |id: String, name: String, about: String| Agent { id, name, about, kind: AgentKind::Codync };
- let mut offer = vec![agent("x".repeat(65), "an id no letter carries".into(), String::new())];
+ let mut offer = vec![agent("x".repeat(257), "an id no letter carries".into(), String::new())];
+ // Forty characters of any script is an address name a letter carries.
+ offer.push(agent("審".repeat(40), "審計".into(), String::new()));
offer.extend((0..300).map(|n| agent(format!("bot-{n}"), "é".repeat(100), "a".repeat(5000))));
let kept = bounded(offer);
assert_eq!(kept.len(), MAX_AGENTS);
- assert_eq!(kept[0].id, "bot-0");
- assert!(kept[0].name.len() <= MAX_AGENT_NAME && kept[0].name.chars().all(|c| c == 'é'));
- assert_eq!(kept[0].about.len(), MAX_ABOUT);
+ assert_eq!(kept[0].id, "審".repeat(40));
+ assert_eq!(kept[1].id, "bot-0");
+ assert!(kept[1].name.len() <= MAX_AGENT_NAME && kept[1].name.chars().all(|c| c == 'é'));
+ assert_eq!(kept[1].about.len(), MAX_ABOUT);
}
}
diff --git a/host/crates/network/src/wire.rs b/host/crates/network/src/wire.rs
index a177718f..6250bb62 100644
--- a/host/crates/network/src/wire.rs
+++ b/host/crates/network/src/wire.rs
@@ -14,8 +14,9 @@ use std::fmt::Write;
pub const ALPN: &[u8] = b"codync-network/0";
pub const MAX_BODY: usize = 64 * 1024;
const MAX_META: usize = 16 * 1024;
-/// The longest `from`, `to` and `reply_to`: an agent's address name (or `agent-<name>`), a letter id.
-const MAX_ADDRESS: usize = 128;
+/// The longest `from`, `to` and `reply_to` in bytes: an agent's address name (40 characters of
+/// any script, a number, `agent-`), a letter id.
+pub const MAX_ADDRESS: usize = 256;
/// The longest letter id (`random_hex(12)` makes 24).
pub(crate) const MAX_ID: usize = 64;
const MAX_FRAME: usize = 1024 * 1024;
@@ -226,6 +227,7 @@ mod tests {
};
assert!(check(&letter(&random_hex(12), "agent-lead".into())).is_ok());
assert!(check(&letter(&random_hex(12), "x".repeat(1 << 20))).is_err());
+ assert!(check(&letter(&random_hex(12), "審".repeat(40))).is_ok(), "any script's address names");
assert!(check(&letter(&"a".repeat(100), "lead".into())).is_err());
assert!(check(&letter("", "lead".into())).is_err());
let mut reply = letter(&random_hex(12), "lead".into());