Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

cmux Python SDK

The package root is the handwritten cmux resource API. It uses opaque prefixed string IDs, tagged selectors, typed snapshots, explicit mutation receipts, structured errors, and cancellable streams. It supports Python 3.9+ with no runtime dependencies. The distribution includes the PEP 561 py.typed marker so type checkers consume its inline annotations.

Install the cmux-sdk distribution. The Python import remains cmux, so it does not overlap the uvx cmux CLI distribution:

python -m pip install cmux-sdk
from cmux import Client, SessionId, WorkspaceId, exact
from cmux.options import RunOptions

with Client() as client:
    session = client.session(
        SessionId("session_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    )
    workspace = session.workspace(
        WorkspaceId("ws_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
    )
    created = workspace.run(
        RunOptions(exact(["printf", "%s\n", "$HOME"]))
    )
    print(created.value.terminal.id)

exact() sends its argv without shell parsing. shell() asks the server to choose the target platform shell. shell_executable() sends [executable, "-lc", script] when the caller needs a specific shell.

Mutations never retry implicitly. Omit idempotency_key to receive a fresh cryptographically random key, or supply one to control replay behavior. Snapshots update only through explicit refresh(). Handles close resources only through their explicit close() methods.

Known catalog snapshots and results are exact dataclasses. Unknown sibling fields are rejected unless the catalog declares an extra map. Terminal reads return types such as TerminalScreenResult, TerminalHistoryResult, and ProcessInfoResult; empty mutations return MutationReceipt.

If a mutation loses its response to a timeout or disconnect, MutationTransportError exposes its operation and exact supplied or generated key.

Synchronous calls can apply one local deadline or cancellation signal:

from cmux import CancellationToken, RequestOptions

cancellation = CancellationToken()
result = client.with_request_options(
    RequestOptions(timeout=1.0, cancellation=cancellation),
    session.ping,
)

After a dispatched terminal.wait or terminal.wait_exit reaches its local deadline or cancellation signal, the SDK confirms request.cancel on the same connection before reusing it. A completion that wins the server race is drained instead. Cleanup failure closes the connection while preserving the original TimeoutError or CancelledError.

Streams retain at most 256 unread messages and 16 MiB. Overflow ends only that stream with a recoverable gap and sends best-effort cancellation. Close the stream or its client explicitly. stream.next(timeout=...) raises cmux.TimeoutError without closing the stream.

Browser frames always carry pointer_frame_seq on the wire. The SDK exposes it as int | None: None means the frame cannot authorize pointer input. Mouse and wheel calls require the exact non-null token from the rendered frame and encode it as an unsigned decimal string:

from cmux import BrowserAttachFrame, BrowserId
from cmux.options import BrowserMouseOptions

browser = session.browser(
    BrowserId("browser_cccccccccccccccccccccccccccccccc")
)
with browser.attach() as frames:
    for event in frames:
        frame = event.item
        if isinstance(frame, BrowserAttachFrame):
            if frame.pointer_frame_seq is not None:
                browser.mouse(BrowserMouseOptions(
                    kind="move",
                    x_px=12.5,
                    y_px=20.0,
                    pointer_frame_seq=frame.pointer_frame_seq,
                ))
            break

The asyncio facade mirrors the resource graph:

import cmux.aio
from cmux import RequestOptions

async with cmux.aio.Client() as client:
    machines = await client.list_machines(
        request_options=RequestOptions(timeout=1.0)
    )

Creation recovery uses session.creation.resolve(correlation_key). Terminal exit waits use terminal.wait_exit(timeout_ms) and return strict pending or exited dataclasses with typed exit, signal, and unknown outcomes.

Destructive layout undo raises ConfirmationRequiredError with a typed preview token, revision, and panes. Retry with that token, its revision, and a new idempotency key.

All eight creation option dataclasses expose correlation_key. Values contain 1 to 128 UTF-8 bytes and remain stable across creation attempts.

Agent state reporting starts from the session, so a new terminal does not need an existing agent-list result:

from cmux import AgentReportOptions

reported = session.report_agent(AgentReportOptions(
    terminal_id=terminal_id,
    state="working",
    source="socket",
))

Each async stream owns its blocking reader worker. A waiting stream does not occupy a request worker. Canceling a stream closes only that stream. Closing the client releases all remaining stream, request, and reader workers.

The generated protocol-v10 client and numeric mux identities are available only from cmux.raw:

from cmux.raw import CmuxClient, COMMANDS

An explicit socket path wins. Otherwise the client checks CMUX_TUI_SOCKET, then CMUX_MUX_SOCKET, then resolves the named session under XDG_RUNTIME_DIR, TMPDIR, or /tmp.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmux_sdk-0.0.0a0.tar.gz (116.1 kB view details)

Uploaded Source

Built Distribution

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

cmux_sdk-0.0.0a0-py3-none-any.whl (97.5 kB view details)

Uploaded Python 3

File details

Details for the file cmux_sdk-0.0.0a0.tar.gz.

File metadata

  • Download URL: cmux_sdk-0.0.0a0.tar.gz
  • Upload date:
  • Size: 116.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for cmux_sdk-0.0.0a0.tar.gz
Algorithm Hash digest
SHA256 8023ff6b4271f5b5bac2fa985639b0f64bee4d71edae740b75f0557dd7e64da6
MD5 b2432c8ebd69cba2c425357437a3097c
BLAKE2b-256 bb7d2ff9ec9c8fb91f79b5637ed6c160d9e8178df901f2df52995c6c18e8edb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cmux_sdk-0.0.0a0.tar.gz:

Publisher: sdk-bootstrap-pypi.yml on manaflow-ai/cmux

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

File details

Details for the file cmux_sdk-0.0.0a0-py3-none-any.whl.

File metadata

  • Download URL: cmux_sdk-0.0.0a0-py3-none-any.whl
  • Upload date:
  • Size: 97.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for cmux_sdk-0.0.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 6dbc3d4d7929a4f2b6dec64f3cce30a69f3e0fdd33641fb16a4ba5fe59f67d78
MD5 8c339f5a7e60a28595f0fa4bb5f0f264
BLAKE2b-256 57e07181e00f64f6d6e17ce0fb4ab4f9b126e7e7da211dbe4b1b3a6dbfafd57e

See more details on using hashes here.

Provenance

The following attestation bundles were made for cmux_sdk-0.0.0a0-py3-none-any.whl:

Publisher: sdk-bootstrap-pypi.yml on manaflow-ai/cmux

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

Release history Release notifications | RSS feed

This release

0.0.0a0 This release

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