Skip to content

Peer Mailboxes ​

loomtty peer gives agents (and scripts) named mailboxes inside loomtty-server. One agent sends a message; another, blocked on loomtty peer recv <name> --wait, wakes up with the message in its output. Nobody polls, nobody types into someone else's terminal, and it works the same between two shells on one machine and between machines.

bash
# reviewer (left running in the background):
loomtty peer recv reviewer --wait

# main:
loomtty peer send reviewer --from main -s "please review" -f notes.md
# delivered (reviewer is waiting)  id k3f9a2-x81mqd
loomtty peer recv main --wait            # now wait for the answer

# reviewer, after waking up and doing the work:
loomtty peer send main --from reviewer --reply-to k3f9a2-x81mqd -f review.md
loomtty peer recv reviewer --wait        # and wait for the next turn

The model ​

  • A mailbox is a name. Names are not registered anywhere: the first send to a name or recv on it creates the mailbox. An agent talking to two others at once uses two names, which keeps the two conversations apart. Names follow the session-name rule (lowercase letters, digits and -).
  • Messages are files. Each mailbox is a directory under loomtty's state directory (mail/<name>/, next to sessions/), with one file per message: queued messages in new/, handed-out ones in seen/. They survive a server restart.
  • Waits are local. recv --wait always waits on the machine it runs on. Only one recv --wait waits per name; a newer one takes over and the older one exits with status 4.
  • The sender makes the hop. send build:builder connects from your machine to the loomtty-server on build through ssh (ssh -W 127.0.0.1:<port>, the same path as remote attach) and drops the message in that machine's mailbox. Servers never talk to each other.
  • Messages are text. The body is UTF-8, at most 512 KiB. For anything bigger, send a path or a git ref. recv prints bodies up to 8 KiB and points to the file for the rest.

Delivery states ​

send tells you what happened right away:

StatusMeaning
delivered (... is waiting)A recv --wait was waiting on that name and now has the message.
queued (... last seen 3m ago, N unread)Nobody is waiting; the next recv gets it.
queued (nobody has used the name ... yet)The name has never been used on that machine: often a typo, or the other side has not started yet.

peer log shows each message's state afterwards:

StateMeaning
queuedStill waiting in the mailbox.
deliveredHanded to a recv, and the owner has not run a peer command since.
readHanded out, and the owner has since run recv or sent a message from this machine, so it moved on to its next step.

At-most-once delivery ​

A message counts as delivered once it is handed to a recv command. If that command belonged to an agent that is already gone (an orphaned background task), the message went to it and nobody read it. Such a message stays delivered in peer log instead of turning read; its file is still in the mailbox's seen/ directory, and peer log (with --json) shows its path. Starting a fresh recv --wait on the name takes over from an orphaned waiter.

Setting up machines ​

On one machine there is nothing to set up: the server must be running (start loomtty, or loomtty-server --headless).

Across machines:

  1. Every machine runs loomtty 0.3.0 or newer; an older server is reported as too old.

  2. The receiving machine accepts tunnelled clients:

    toml
    [remote]
    enabled = true
  3. The sending machine has a saved host for it, and ssh logs in without a prompt (peer runs ssh with BatchMode=yes):

    toml
    [[remote.hosts]]
    name = "build"
    host = "[email protected]"
  4. The sending machine has a name of its own, so the recipient can reply to <that name>:<your name>. Use the name the other machines give it in their [[remote.hosts]]:

    toml
    [peer]
    host = "laptop"

    Restart loomtty-server after setting or changing it: the server reads [peer] host only when it starts.

Messages from another machine arrive as laptop:main; replying to exactly that address goes back through the recipient's own [[remote.hosts]] entry for laptop.

Limits ​

  • peer log on a machine shows the messages that machine received. A conversation between two machines is split between their two logs.
  • A delivered message whose recipient replied to another machine and then stopped stays delivered: the reply went to the other machine's server, not this one. Running recv --wait again (the normal next step) marks it read.
  • Message files in seen/ are not cleaned up automatically. Deleting them by hand is safe.

See the CLI reference for every flag and exit status.

Released under the AGPL-3.0-only License.