shell-session-manager
shell-session-manager provides async subprocess sessions that can be resumed
across multiple calls. It drains stdout/stderr in background asyncio tasks,
supports incremental stdin writes, exposes short session ids, and manages
best-effort cleanup for long-lived command sessions.
Command construction is intentionally out of scope: callers should pass the exact command string they want to execute, including any shell, SSH, PTY, or environment bootstrap wrappers.
Usage
import anyio
from shell_session_manager import ShellSession, ShellSessionOptions
async def main() -> None:
async with ShellSession(
"python -u -c 'import sys; print(\"ready\"); line = sys.stdin.readline(); print(line.upper(), end=\"\")'",
options=ShellSessionOptions(timeout_seconds=1),
) as session:
stdout, stderr, code = await session.next()
print(stdout.decode(), stderr.decode(), code) # ready\n, "", None
stdout, stderr, code = await session.next(b"hello\n")
print(stdout.decode(), stderr.decode(), code) # HELLO\n, "", 0
anyio.run(main)
For multiple long-lived sessions, use ShellSessionManager:
import anyio
from shell_session_manager import ShellSessionManager
async def main() -> None:
async with ShellSessionManager() as manager:
session_id = await manager.new_shell("python -c 'print(42)'")
stdout, stderr, returncode = await manager.next(session_id)
print(stdout.decode(), stderr.decode(), returncode)
anyio.run(main)
shellctl server
Run the HTTP API locally with:
pdm run shellctl serve --listen 127.0.0.1:8765
Pass --auth-token your-token when you want bearer auth enforced. shellctl serve also reads SHELLCTL_AUTH_TOKEN, so you can export the token instead of
passing the flag. Leave the flag/env var unset or empty to start without
requiring an Authorization header.
shellctl network CLI
Job-management commands now talk to a running shellctl serve instance. Start
the server first, then point the CLI at it with --base-url or
SHELLCTL_BASE_URL when you are not using the default http://127.0.0.1:8765.
Authenticated job commands also read SHELLCTL_AUTH_TOKEN, and --auth-token
overrides the environment when you need a different bearer token for one call.
export SHELLCTL_BASE_URL=http://127.0.0.1:8765
export SHELLCTL_AUTH_TOKEN=your-token
The public health endpoint ignores auth configuration, but the option is still accepted for a consistent CLI surface.
pdm run shellctl health
pdm run shellctl run 'echo Hello World'
pdm run shellctl wait <job-id> --offset <offset>
pdm run shellctl input <job-id> $'hello\n' --offset <offset>
pdm run shellctl tail <job-id>
pdm run shellctl status <job-id>
pdm run shellctl list --status running
pdm run shellctl terminate <job-id>
pdm run shellctl delete <job-id> --force
These commands emit compact JSON on stdout. shellctl list prints a bare JSON
array matching ShellctlClient.list_jobs(), while the other commands print one
JSON object each. SDK failures, HTTP errors, and network errors emit compact
JSON error objects on stderr and exit non-zero.
Metadata
Release files for shell-session-manager 2.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| shell_session_manager-2.4.1.tar.gz | 68.2 kB | With provenance | Details for shell_session_manager-2.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| shell_session_manager-2.4.1-py3-none-any.whl | Python 3 | none | any | Details for shell_session_manager-2.4.1-py3-none-any.whl |
Total release size: 126.7 kB
Release files / shell_session_manager-2.4.1.tar.gz
| Download URL | shell_session_manager-2.4.1.tar.gz |
|---|---|
| Size | 68.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad901852fbf4a84bb07dade5ddf65d28c546fb676d883aa03f743500a1dac5fe
|
|
BLAKE2b-256 checksum How to use checksums |
01300ee49da0f27f9f6eb97c0286e75f89766d5ac8f7a5a713f8a851705e91c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.
Transparency logRelease files / shell_session_manager-2.4.1-py3-none-any.whl
| Download URL | shell_session_manager-2.4.1-py3-none-any.whl |
|---|---|
| Size | 58.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87a3c95d7060ba5ca2010d663876a4d32149b5fcf9a2081a217564cb127c2f3d
|
|
BLAKE2b-256 checksum How to use checksums |
7de751c74304814cda5edbb2425f34f8545beed2ef2d833323e4b43883dc84e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.
Transparency logSecurity for shell-session-manager 2.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for shell_session_manager-2.4.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.