Skip to main content

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

muxplex_client-0.47.3.tar.gz (25.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

muxplex_client-0.47.3-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file muxplex_client-0.47.3.tar.gz.

File metadata

  • Download URL: muxplex_client-0.47.3.tar.gz
  • Upload date:
  • Size: 25.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for muxplex_client-0.47.3.tar.gz
Algorithm Hash digest
SHA256 c805c46a3c9cb815e06c8ad176fbbc3e24ea1118719fec770191452ee6594f2b
MD5 63b151c5dfbd226d9c22d33311c42ab7
BLAKE2b-256 d999fae677954e2d2f8737364c7b20fc0dfeffd287ee35fbf25d907bee17a506

See more details on using hashes here.

Provenance

The following attestation bundles were made for muxplex_client-0.47.3.tar.gz:

Publisher: publish.yml on bkrabach/muxplex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file muxplex_client-0.47.3-py3-none-any.whl.

File metadata

  • Download URL: muxplex_client-0.47.3-py3-none-any.whl
  • Upload date:
  • Size: 25.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for muxplex_client-0.47.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2210deab3143a661c7f06dbfba4c4a85180f6cbc466390433f4b4049e07ebc04
MD5 f8fc9e4d3290049f39a2324d94078424
BLAKE2b-256 7c80eb2404920b6bba5e9854c56b8fd83717c4820ac0c205be97225b6b4ea85e

See more details on using hashes here.

Provenance

The following attestation bundles were made for muxplex_client-0.47.3-py3-none-any.whl:

Publisher: publish.yml on bkrabach/muxplex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.58.2

2 files

0.58.1

2 files

0.58.0

2 files

0.57.3

2 files

0.57.2

2 files

0.57.1

2 files

0.57.0

2 files

0.56.2

2 files

0.56.1

2 files

0.56.0

2 files

0.55.2

2 files

0.55.1

2 files

0.55.0

2 files

0.54.0

2 files

0.53.0

2 files

0.52.0

2 files

0.50.0

2 files

0.49.1

2 files

0.49.0

2 files

0.48.3

2 files

0.48.2

2 files

0.48.1

2 files

0.48.0

2 files

0.47.12

2 files

0.47.11

2 files

0.47.10

2 files

0.47.9

2 files

0.47.8

2 files

0.47.7

2 files

0.47.6

2 files

0.47.5

2 files

0.47.4

2 files

This release

0.47.3 This release

2 files

0.47.2

2 files

0.47.1

2 files

0.47.0

2 files

0.46.1

2 files

0.46.0

2 files

0.45.1

2 files

0.45.0

2 files

0.44.0

2 files

0.43.0

2 files

0.42.0

2 files

0.41.0

2 files

0.40.0

2 files

0.39.0

2 files

0.38.1

2 files

0.38.0

2 files

0.37.0

2 files

0.36.1

2 files

0.36.0

2 files

0.35.0

2 files

0.34.0

2 files

0.33.0

2 files

0.32.0

2 files

0.31.6

2 files

0.31.5

2 files

0.31.4

2 files

0.31.3

2 files

0.31.2

2 files

0.31.1

2 files

0.30.1

2 files

0.30.0

2 files

0.29.0

2 files

0.28.0

2 files

0.27.0

2 files

0.26.1

2 files

0.26.0

2 files

0.25.0

2 files

0.24.0

2 files

0.23.0

2 files

0.22.0

2 files

0.21.0

2 files

0.20.1

2 files

0.20.0

1 file

0.19.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page