# ptymini > Drive line-oriented interactive programs in the background: REPLs, shells, ssh, debuggers. Start a pty session once, send input later, wait a bounded time for the reply, and read what arrived since your last look. Use this for CLI work. Use `fastmux` for TUIs, rich terminal apps, and terminals shared with the user. Base URL: https://AnswerDotAI.github.io/ptymini/ - `ptymini.bg` (bgterm): sync, sid-based, straight into the Rust pty core, no event loop; `ptymini.core`: asyncio `PtySession`/`PtyRegistry` (multi-client attach, replay buffers, named registry; `doc(ptymini.core)`) - bgterm sessions: in-process, end with it; PTY defaults: `cols=4096`, no echo, non-canonical, LF output, `ISIG` on /no line wrap, echoed input, `\r\n`, or 1 KB line truncation ```python sid = start_bgterm(['ipython', '--simple-prompt']) poll(sid, 5000, until=r'In \[1\]') r = write_stdin(sid, '2+2\n', 5000, until=r'In \[2\]') close_bgterm(sid) ``` - ssh: `start_bgterm(['ssh', '-T', host, 'bash --norc --noprofile'])`; `-tt` only when remote needs a PTY /`-T` skips remote rc, ANSI prompts, and remote echo - waits (`wait_ms`, `until=`, `settle_ms`): as `fastmux.bg`, but event-driven, no `interval_ms`; bounded: timeout returns what arrived; dead child ends any wait at once - `until`: text only the awaited reply produces, e.g. next prompt; sees only this call's output /reading consumes the stream ## API - [ptymini.core](api/core.md): Asyncio PTY sessions, offset-tracked output rings, and named session registries. - [ptymini.bg](api/bg.md): Synchronous, cursor-paged PTY sessions for scripts, kernel tools, and LLM agents.