Skip to main content
Pre-release

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

shell-use (Python)

A Python client for the shell-use terminal daemon.

The shell-use binary must be on your PATH (or point to it with the SHELL_USE_BIN environment variable or the binary= argument). The client talks to the per-session daemon directly over its local socket (a named pipe on Windows, a Unix socket elsewhere) and starts the daemon automatically.

Install

pip install shell-use

Requires Python 3.8+.

Quick start

import asyncio
from shell_use import ShellUse

async def main():
    async with ShellUse() as su:
        await su.open()
        await su.submit("echo hello")
        await su.wait_command()
        await su.expect_text("hello")
        await su.expect_exit_code(0)

asyncio.run(main())

Drive a full-screen TUI:

async with ShellUse("vim-session") as su:
    await su.run("vim", "file.txt")
    await su.wait_idle()
    await su.press("i")
    await su.type("some text")
    await su.press("Escape", ":", "w", "q", "Enter")
    await su.wait_exit()

Errors

Every failure maps to one of the daemon's exit codes:

Exception Exit code Meaning
ExpectationError 1 an expect/wait condition was not met
UsageError 2 invalid argument (e.g. a bad regex)
NoSessionError 3 no active session
DaemonError 4 daemon could not be reached or started
VersionMismatchError 4 the daemon's version differs from this package
InternalError 5 internal daemon error

All derive from ShellUseError. wait_* and expect_* raise ExpectationError on failure.

On its first call, a client checks that the running daemon's version matches the package version and raises VersionMismatchError if they differ. Stop the daemon (daemon_stop) so it restarts with the current binary, or point SHELL_USE_BIN at a matching one.

API

ShellUse(session="default", *, binary=None, home=None) mirrors the CLI: open / run, type / write, submit, press / keys, mouse.click|move|down|up|drag|scroll, resize, signal / kill, state, text, cells, get (+ get_command / get_output / get_exit_code / get_cwd / get_cursor / get_size), screenshot, wait_text / wait_idle / wait_command / wait_exit, expect_text / expect_exit_code / expect_output / expect_snapshot, and close.

Module-level helpers: sessions(), close_all(), daemon_status(), daemon_stop(), get_recording().

Configuration

Variable Purpose
SHELL_USE_BIN path to the shell-use binary
SHELL_USE_SESSION default session name
SHELL_USE_HOME daemon state directory (sockets, pids)

Download files

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

Source Distribution

shell_use-0.0.1b4.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

shell_use-0.0.1b4-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file shell_use-0.0.1b4.tar.gz.

File metadata

  • Download URL: shell_use-0.0.1b4.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for shell_use-0.0.1b4.tar.gz
Algorithm Hash digest
SHA256 db4b1015f395b4a2f702d80ee3af1a628dc6b9c4f48867b390d3a09c4192ae11
MD5 5a81c3f0fa5e11fb84d7f01613117ac8
BLAKE2b-256 dacbd7be18df445d5fc07f80a980193dff19e85ff1a6369afa844c0eb765251e

See more details on using hashes here.

Provenance

The following attestation bundles were made for shell_use-0.0.1b4.tar.gz:

Publisher: release.yml on microsoft/shell-use

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

File details

Details for the file shell_use-0.0.1b4-py3-none-any.whl.

File metadata

  • Download URL: shell_use-0.0.1b4-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for shell_use-0.0.1b4-py3-none-any.whl
Algorithm Hash digest
SHA256 fa3e095b8680b0ac5fddee2d6ca25709157a90a672060ec721c90368c86512c6
MD5 fe9e3afc5e208dcff8a14a80be5168de
BLAKE2b-256 7b3a27d2e723c40f919e14f0e99fc683c9d35e297293412df3a56c39be2123dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for shell_use-0.0.1b4-py3-none-any.whl:

Publisher: release.yml on microsoft/shell-use

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.0.1

2 files

This release

0.0.1b4 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