Skip to content
sandoverPublic

Latest commit

 

History

985 Commits

Folders and files

Repository files navigation

Plasmite

CI Homebrew Tap crates.io PyPI npm Go Reference License: MIT

A pipe that remembers.

What would make it pleasant and predictable for programs (and agents) to communicate?

  • Programs come and go... so message channels should outlast them
  • Machines crash... so channels should live on disk
  • Disks are finite... so channels should have a bounded size
  • Brokers bring complexity and ceremony... so local messaging shouldn't need one
  • People need to see what's happening... so messages should be plain JSON
  • Schemas are great... but schemas should be optional

So, there's Plasmite.

Programs and scripts (shell, Rust, C, Python, Go or JS) send JSON messages into a channel called a pool. A pool is a ring buffer on disk: it keeps the most recent messages and overwrites the oldest when it fills. Three verbs, in the CLI and every library:

  • feed sends a message
  • fetch reads what's already in the pool, then stops
  • follow waits for new messages (like tail -f)

On the command line, pls is short for plasmite.

Local message passing

Read down: each row happens after the one above.

Alice in Terminal 1 Alice in Terminal 2
1 Creates a message pool
pls pool create channel
2 Starts watching
pls follow channel
3 Sends a message
pls feed channel '{"msg":"hello world"}'
Sees it
14:02:11 #1 {"msg":"hello world"}

The message stays in the pool, so a later reader can fetch it with pls fetch channel --last 1. To pick up after a restart, save the sequence of the last message you handled and follow from the next one. If you saved sequence 42, run pls follow channel --since 43. See the restart recipe.

Remote message passing

Remote pools take the same commands as local ones.

Alice in Terminal 1 Alice in Terminal 2 Bob (another machine)
4 Starts the server in the background
pls serve https://alice.local:9743 &
5 Invites Bob, then sends him the address and key
pls access invite Bob
6 Connects, pastes in the key, and then watches
pls access connect https://alice.local:9743
pls follow https://alice.local:9743/channel
7 Sends
pls feed channel '{"msg":"hi all"}'
Sees it
14:03:05 #2 {"msg":"hi all"}
Sees it
14:03:05 #2 {"msg":"hi all"}

Bob can also browse the pools at https://alice.local:9743 once his browser trusts Alice's certificate. See the serving guide.

Agents

Agents come and go too, so pools suit them. Claude Code, Codex or any other MCP client can share a pool, and an agent that starts fresh reads the history to catch up.

claude mcp add --transport stdio plasmite -- pls mcp                      # local pools
claude mcp add --transport http plasmite https://alice.local:9743/mcp     # Alice's server, nothing to install

Alice's agent posts "tests pass on fix-login". Bob's agent picks it up on its next turn, even with a fresh context. Alice and Bob watch the whole exchange with pls follow channel, and can step in with pls feed. Your client's default MCP settings work. See Plasmite for agents.

With OpenCode, a tagged message can even wake an idle agent: Bob's agent sleeps until Alice's handoff lands. (How; beta, and OpenCode only for now.)

Fire-and-forget over UDP

On a trusted network, Alice's server can also take UDP datagrams. A UDP sender fires off a message and moves on, where HTTP waits for the server to confirm the write. That suits sensors and other chatty senders that can live with an occasional lost message.

kill %1 && pls serve https://alice.local:9743 --udp=0.0.0.0:9701 &   # Alice restarts her server with UDP on
pls feed udp://alice.local:9701/channel '{"temp_c": 21.4}'              # Bob

How it works

A pool is a .plasmite file in ~/.plasmite/pools/ by default. Any number of programs can feed and follow the same pool.

Every message has four fields:

  • data: your JSON payload
  • meta: labels you attach with --tag and the sender name when you write with a server access key
  • seq: message index, counting up from 1
  • time: when the pool stored it

fetch and follow can start wherever:

pls fetch channel --last 5         # the last 5 messages, then stop
pls follow channel --since 10m     # the last 10 minutes, then keep waiting

Pipes just work. Pipe fetch or follow into feed to copy messages between pools, tags and all. jq and similar tools work great.

When to use Plasmite

Use Plasmite when programs or agents need to share small, structured messages and catch up after a restart. A pool keeps recent messages in a fixed-size file. Programs on the same machine open the file directly, and programs on other machines connect through a Plasmite server. The cookbook shows agent handoffs, CI gates, sensor feeds, and replay.

Performance

Fast, small and quiet. Measured through the local APIs on an Apple M5 Pro Mac, with a 2.0 development build and medians of seven runs:

Language Publish small messages (msg/s) Peak memory while publishing
Rust 404,900 17 MiB
C 309,200 18 MiB
Go 213,800 28 MiB
Python 90,600 40 MiB
JavaScript (Node) 84,800 67 MiB

Delivery is quick: at 250 messages per second with 1 KiB payloads, a message reached one reader in 0.13 ms and four readers in 0.19 ms (median p95), and every reader got every message. A reader waiting on a quiet pool uses under 0.1% of one CPU core.

See the live-stream measurements and the full 2.0 benchmarks, including replay.

Install

macOS and Linux (Homebrew)

brew install sandover/tap/plasmite

Installs the CLI (plasmite + pls) and the full SDK (libplasmite, C header, pkg-config). Go links against this SDK, so install it first if you use Go.

Python

uv tool install plasmite   # CLI
uv add plasmite            # library, in a uv project

Wheels for macOS, Linux x86_64 and Windows x86_64 bundle the CLI and native library.

Node

npm i -g plasmite          # CLI
npm i plasmite             # library

Needs Node.js 24 or newer, on macOS, Linux x86_64 or Windows x86_64.

Rust

cargo install plasmite     # CLI
cargo add plasmite         # library

Go

go get github.com/sandover/plasmite/bindings/go/v2/local@v2.0.0

Everything else

GitHub Releases has archives of the CLI and SDK for macOS and Linux, including preview builds for Linux ARM and Raspberry Pi. See the distribution guide for every platform.

Upgrading from 1.x? See the 2.0 upgrade guide.

Learn more

pls --help lists every command; pls COMMAND --help lists its options.

Inspired by Oblong Industries' Plasma.

License

MIT. See THIRD_PARTY_NOTICES.md for vendored code.

Releases

Packages

Used by

Contributors

Languages