muxplex-client
Typed sync/async HTTP client for the muxplex tmux-session-dashboard API.
Ships as its own PyPI distribution (import name muxplex_client) so a
consumer that only needs to make ~12 HTTP calls -- a Stream Deck sidecar, an
Amplifier tool module -- never has to install the server's dependencies
(fastapi, uvicorn, python-pam, ...) or its muxplex server console script.
See ../muxplex-client-design.md for the full
design rationale.
Install
pip install muxplex-client
Runtime dependency: httpx>=0.27.0. Nothing else -- no muxplex server
dependency, no console script installed.
Usage
Synchronous:
from muxplex_client import MuxplexClient
with MuxplexClient("https://your-server:8088", "federation-key") as client:
for session in client.sessions():
if session.bell.needs_attention:
print(f"{session.name} needs attention")
Asynchronous (Amplifier tool modules, or any asyncio caller):
from muxplex_client import AsyncMuxplexClient
async with AsyncMuxplexClient("https://your-server:8088", "federation-key") as client:
result = await client.run_shell_command("my-session", "pytest -q")
print(result.exit_code, result.elapsed)
A localhost caller needs no credential -- federation_key=None is the
default and is fine when running on the same host as the server.
What's in here vs. what isn't
See muxplex-client-design.md §3 for the full included/excluded endpoint
table and rationale. Notably excluded: PATCH /api/settings (highest
blast-radius operation in the API; a v2 concern requiring CAS + 409 retry +
backstop discrimination), all federation endpoints (server-to-server
protocol, no client consumer), and /api/internal/setup-hooks (internal,
self-healing as of server v0.18.0).
Version alignment
muxplex_client.__version__ is cut in lockstep with the muxplex server
version -- one vX.Y.Z tag publishes both wheels. This is provenance
("cut against server X"), not a runtime requirement: the client declares no
dependency on the muxplex package and enforces no version at runtime.
MIN_SERVER_VERSION backs an opt-in check_server() helper the caller may
call; it is never invoked automatically.
The load-bearing correctness mechanism is
muxplex/tests/test_client_contract.py, living in the server's own test
suite: it drives this client over httpx.ASGITransport against the real
FastAPI app and asserts every field the client parses actually exists on the
real response, that mirrored constants (KNOWN_KEYS, MAX_CAPTURE_LINES,
DEFAULT_CAPTURE_LINES) equal their server originals, and that
Bell.needs_attention agrees with the server's own predicate across a truth
table.
The shell-command sentinel
run_shell_command() (and the lower-level muxplex_client.sentinel module)
implements the completion-detection convention from AGENT_GUIDE.md §6.2/§6.4:
wrap a command with ; rc=$?; ... ; echo "MUXPLEX_DONE_<token>_EXIT_$rc" and
poll the pane for the marker.
This assumes the target pane is an idle POSIX shell prompt. It is not a
general HTTP contract -- it fails (types a garbage line into whatever is
actually running, then hangs until timeout) against vim, a REPL, less, a
TUI, an ssh session, or a non-POSIX shell without a matching exit_expr.
The one correctness rule worth calling out explicitly: matching must be
digit-anchored (MUXPLEX_DONE_<token>_EXIT_(\d+)), never a bare-token
substring check. tmux echoes the literal, unexpanded ...EXIT_$? into the
pane the instant you send the line -- before the shell has even run it -- so
a bare-token match reports "done" with a bogus exit code immediately. See
muxplex_client/sentinel.py's docstring and tests/test_sentinel.py's
digit-anchor regression test.
Development
uv sync --extra dev # from this directory, or from the repo root via the
# [tool.uv.workspace] declaration
uv run pytest
tests/ is pure -- no network, no server import, and passes with muxplex
not installed at all.
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 muxplex_client-0.25.0.tar.gz.
File metadata
- Download URL: muxplex_client-0.25.0.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63ebcd97cb42c35ee1e172e2e2d573fd37ae52aab9496c04cbdf684b39ee9bf1
|
|
| MD5 |
6486299a7b7f950600e85dfe4344be83
|
|
| BLAKE2b-256 |
58667b487f72a957ee308e8e856cee553936a704e234eb827ad40cba5a310b56
|
Provenance
The following attestation bundles were made for muxplex_client-0.25.0.tar.gz:
Publisher:
publish.yml on bkrabach/muxplex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
muxplex_client-0.25.0.tar.gz -
Subject digest:
63ebcd97cb42c35ee1e172e2e2d573fd37ae52aab9496c04cbdf684b39ee9bf1 - Sigstore transparency entry: 2287215029
- Sigstore integration time:
-
Permalink:
bkrabach/muxplex@741e7b2c835c74e867819a8d1e4ab061cd94c055 -
Branch / Tag:
refs/tags/v0.25.0 - Owner: https://github.com/bkrabach
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@741e7b2c835c74e867819a8d1e4ab061cd94c055 -
Trigger Event:
push
-
Statement type:
File details
Details for the file muxplex_client-0.25.0-py3-none-any.whl.
File metadata
- Download URL: muxplex_client-0.25.0-py3-none-any.whl
- Upload date:
- Size: 18.6 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 |
2e24e1ef7197663449ada8db6b57bb4ff1e40a40afd408c89263b0a7be971f3b
|
|
| MD5 |
2143eba751e304d76f43bcd3bbd97fe5
|
|
| BLAKE2b-256 |
aae4905a6d1b63d1c7b94f9025f1c2555889d4c4a4bbfae2f3a1d039155967b4
|
Provenance
The following attestation bundles were made for muxplex_client-0.25.0-py3-none-any.whl:
Publisher:
publish.yml on bkrabach/muxplex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
muxplex_client-0.25.0-py3-none-any.whl -
Subject digest:
2e24e1ef7197663449ada8db6b57bb4ff1e40a40afd408c89263b0a7be971f3b - Sigstore transparency entry: 2287215083
- Sigstore integration time:
-
Permalink:
bkrabach/muxplex@741e7b2c835c74e867819a8d1e4ab061cd94c055 -
Branch / Tag:
refs/tags/v0.25.0 - Owner: https://github.com/bkrabach
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@741e7b2c835c74e867819a8d1e4ab061cd94c055 -
Trigger Event:
push
-
Statement type: