ptymini fills the gap between ptyprocess (a raw pty fd), pexpect (sync expect loops), and terminado (a pty server welded to tornado): asyncio-native pty sessions. A PtySession is one spawned pty that any number of clients can attach to as independent byte streams, each primed from a byte-bounded replay buffer — so a reconnecting client resumes with recent scrollback instead of a blank screen. The ring and the pty process live in a compiled Rust core; the asyncio surface is pure Python.
A PtyRegistry adds named get-or-create sessions, injected shell setup (rc), and inactivity culling. It carries no server, no framework, and no session persistence beyond the process. Web exposure belongs to the embedding app (e.g. jupygate), and durable session management belongs to tmux.
ptymini.bg is the sync surface, for callers outside an event loop: kernel tools, plain scripts, an LLM deciding between actions. It is the bgterm API, folded in, with sid-named sessions and blocking calls. The wait parameters are fastmux.bg’s. wait_ms bounds the wait for new output. until= returns as soon as the accumulated text matches that regex. settle_ms keeps collecting until output has stopped for that long.
$ pip install ptymini