tmux-kit
Async, argv-exec tmux session-management primitives, extracted from
muxplex (extraction design:
docs/plans/2026-08-08-tmux-lib-extraction-plan.md; the move to this
repo + PyPI: docs/plans/2026-08-09-tmuxkit-own-repo-and-pypi-plan.md --
both live in the muxplex repo, which remains the archaeological record for
this library's pre-2026-08-08 history).
Named for tmux, not for muxplex: this is a library about a tmux server,
usable by any application that manages tmux sessions. muxplex is its first
consumer. Since the split, each project has its own repo, its own version
line, and its own release cadence -- muxplex pins an exact tmux-kit==
version and bumps it deliberately (see the pyproject.toml note in this
repo, and the muxplex repo's own dependency declaration).
stdlib only. No fastapi, no httpx, no server code. Configuration is injected, never read (§4.3): no function in this package knows that a settings file exists.
Modules
| Module | Provides |
|---|---|
tmux_kit.proc |
run_tmux(), tmux_env(socket_dir) — argv+env plumbing, TmuxError carrying tmux's stderr |
tmux_kit.spawn |
spawn_session(name, resolved_template, env=...) — cgroup-escaped, with the exists-after-nonzero-exit (TTY-attach) tolerance |
tmux_kit.names |
SESSION_NAME_RE, is_valid_session_name, is_tmux_stable_name, rename_session — security-load-bearing name validation |
tmux_kit.observe |
probe_tmux_epoch, enumerate_sessions, pane capture, snapshot caches |
tmux_kit.presence |
the manifest presence rule — pure functions, no I/O; unknown top-level keys round-trip verbatim (§13.3) |
tmux_kit.bell |
bell detection (poll_bell_flag) + build_alert_bell_hook() — the sole legal run-shell construction site, always silent |
tmux_kit.keys |
typed-input argv builders and the allowlist fence mechanism |
tmux_kit.cgroup |
should_escape, wrap_exec_argv, wrap_shell_argv — the 44-session systemd cgroup incident, packaged |
Sharing one tmux server between two apps
The tmux server is a shared singleton and some of its state is a single
global slot. Before shipping a second consumer on a host that also runs
muxplex, read plan §17 — the alert-bell hook slot (last writer wins,
silently), presence cross-talk (scope your observations or your cold start
freezes the other app's sessions into your restore plan), fence overlap,
and session-name collisions.
Versioning
0.x semantics — no semver promise yet. First release is 0.1.0 (the
0.44.0 numbering used inside the muxplex monorepo was a pin-repair
artifact that the rename to tmux-kit voided; see
docs/plans/2026-08-09-tmuxkit-own-repo-and-pypi-plan.md §4 in the
muxplex repo for the full reasoning). Note the PyPI distribution name
uses a hyphen (tmux-kit) while the Python import package uses an
underscore (tmux_kit), because hyphens are illegal in Python
identifiers (cf. python-dateutil -> dateutil):
# Public installs (primary path):
dependencies = ["tmux-kit==0.1.0"]
# Pinned git install (e.g. a managed environment that cannot reach
# public PyPI -- see CONSUMERS.md):
# tmux-kit @ git+https://github.com/bkrabach/tmux-kit@v0.1.0
import tmux_kit
Improvements flow both ways as PRs against this repo — never a copy into a consumer (a file in a consumer that is byte-similar to a file here is the incident this whole extraction exists to prevent, regardless of intent).
Tests
This repo's own tests/ directory carries every incident test that moved
with the code (the 44/52-lost-session presence rule, the multi-window bell
finding, the .->_ mangling refusal, the casefold+fnmatchcase allowlist
fence, the cgroup-escape guards), plus the differential harness
(pytest -m differential, replayed against fleet-recorded real-tmux data)
and a real-tmux integration suite (pytest -m integration, isolated -L
socket). Run the full suite locally:
uv sync --extra dev
uv run pytest
CI (.github/workflows/test.yml) runs the full suite -- including
-m integration and -m differential unconditionally, since a CI runner
has no live muxplex to endanger -- on Python 3.11/3.12/3.13, Linux and
macOS.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tmux_kit-0.1.0.tar.gz.
File metadata
- Download URL: tmux_kit-0.1.0.tar.gz
- Upload date:
- Size: 58.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5815cf98cc403de9f258c52233bb96c9b0a0838a457805df0b092b9b04fa96d
|
|
| MD5 |
6901cac015af68f579512b0fb3737cca
|
|
| BLAKE2b-256 |
0d1728f70cfbaa712f3c9697277213e402ddb4b52dda32191d123d8e1b203cb2
|
Provenance
The following attestation bundles were made for tmux_kit-0.1.0.tar.gz:
Publisher:
publish.yml on bkrabach/tmux-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tmux_kit-0.1.0.tar.gz -
Subject digest:
d5815cf98cc403de9f258c52233bb96c9b0a0838a457805df0b092b9b04fa96d - Sigstore transparency entry: 2386630259
- Sigstore integration time:
-
Permalink:
bkrabach/tmux-kit@6b3fa379458395e86069e6de6c5365be0b122775 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bkrabach
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6b3fa379458395e86069e6de6c5365be0b122775 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tmux_kit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tmux_kit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 39.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac58e071ec7b29e7b6e7034223f89fe561f3e8cbf1c257e7103a20b6debe4fcd
|
|
| MD5 |
8c3a19584eefff306bd08b294199d465
|
|
| BLAKE2b-256 |
d04b309bb2d12d1a76676b935c90df5362d4cf81e34c42062cbeb451d7c3cdca
|
Provenance
The following attestation bundles were made for tmux_kit-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on bkrabach/tmux-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tmux_kit-0.1.0-py3-none-any.whl -
Subject digest:
ac58e071ec7b29e7b6e7034223f89fe561f3e8cbf1c257e7103a20b6debe4fcd - Sigstore transparency entry: 2386630265
- Sigstore integration time:
-
Permalink:
bkrabach/tmux-kit@6b3fa379458395e86069e6de6c5365be0b122775 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bkrabach
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6b3fa379458395e86069e6de6c5365be0b122775 -
Trigger Event:
push
-
Statement type: