Typed Python interface for the Headless CLI
Project description
Headless Python SDK
Typed sync and async interfaces for the
headless command-line tool.
The CLI remains the execution engine and the authority for option validation.
Requirements
- Python 3.10 or newer
- Node.js 22 or newer
- A
headlessexecutable onPATH
You can select a different executable with binary=...,
HEADLESS_CLI_BIN, or HEADLESS_BIN, in that order.
Usage
from headless_cli import Headless
headless = Headless()
result = headless.run(
"codex",
prompt="Review this repository",
model="gpt-5",
reasoning_effort="high",
allow="read-only",
)
print(result.final_message)
headless.sessions.send("bughunt", prompt="Continue the fix")
headless.sessions.launch("review", "codex", prompt="Review the repository")
headless.runs.message("auth", "worker-1", prompt="Fix tests", background=True)
headless.cron.pause("inbox-triage")
headless.docker.doctor()
The high-level read and run methods use Headless' versioned SDK protocol.
stream() yields parsed SdkTrace, SdkResult, and SdkError envelopes.
Prompts use stdin wherever the CLI permits, keeping them out of process
argument lists.
Protocol compatibility is checked on the first structured operation and
cached for the client lifetime. If the installed CLI is too old, the SDK
raises HeadlessVersionError with an upgrade command. Constructing a client
never starts a subprocess.
Structured methods raise on SDK error envelopes by default. Pass
check=False to receive a typed SdkError value instead.
for event in headless.stream(["codex"], input="Review this diff"):
print(event)
Use invoke() as the raw escape hatch for new or uncommon CLI features:
command = headless.invoke(["--help"])
print(command.stdout)
Runs using legacy raw-output or interactive flags (json, debug, tmux,
or print_command) return sdk=None. Read their raw output through
stdout; final_message is intentionally empty because those modes do not
provide a normalized final-message result.
Interactive attach inherits the current terminal:
headless.sessions.attach("bughunt")
sessions.launch(name, ...) creates a managed tmux session using
--tmux --name. Native durable agent sessions remain available through
run(..., session=name).
Async methods have the same shape:
from headless_cli import AsyncHeadless
headless = AsyncHeadless()
result = await headless.run("claude", prompt="Fix the failing tests")
The package has no runtime Python dependencies.
Project details
Release history Release notifications | RSS feed
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 headless_cli-0.5.0.tar.gz.
File metadata
- Download URL: headless_cli-0.5.0.tar.gz
- Upload date:
- Size: 28.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a645eb4b72b374622162d1a8aed36b1489558f3ffdc9cc6f147b41d7f8d39e31
|
|
| MD5 |
ad724db8b74c266dcb5975816e6351a5
|
|
| BLAKE2b-256 |
f64c0122c137bb318a9cc61d439dccc8f8c41b0338a6556539dbfd82c733ad45
|
Provenance
The following attestation bundles were made for headless_cli-0.5.0.tar.gz:
Publisher:
release.yml on RobertTLange/headless-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
headless_cli-0.5.0.tar.gz -
Subject digest:
a645eb4b72b374622162d1a8aed36b1489558f3ffdc9cc6f147b41d7f8d39e31 - Sigstore transparency entry: 2257155495
- Sigstore integration time:
-
Permalink:
RobertTLange/headless-cli@a909ff8c8c036079d4587186c3520fddb1d69d74 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/RobertTLange
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a909ff8c8c036079d4587186c3520fddb1d69d74 -
Trigger Event:
release
-
Statement type:
File details
Details for the file headless_cli-0.5.0-py3-none-any.whl.
File metadata
- Download URL: headless_cli-0.5.0-py3-none-any.whl
- Upload date:
- Size: 30.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7d8a7db20e33dc83a5da835c5ebcb404d61c3eee3527532f9341e55c9cfe2f3
|
|
| MD5 |
36d2dffefacc509bb60ffe18865e6518
|
|
| BLAKE2b-256 |
681278a137eaf0079797f92bd693addef526328db4136e2a3ea818148b494438
|
Provenance
The following attestation bundles were made for headless_cli-0.5.0-py3-none-any.whl:
Publisher:
release.yml on RobertTLange/headless-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
headless_cli-0.5.0-py3-none-any.whl -
Subject digest:
f7d8a7db20e33dc83a5da835c5ebcb404d61c3eee3527532f9341e55c9cfe2f3 - Sigstore transparency entry: 2257155511
- Sigstore integration time:
-
Permalink:
RobertTLange/headless-cli@a909ff8c8c036079d4587186c3520fddb1d69d74 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/RobertTLange
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a909ff8c8c036079d4587186c3520fddb1d69d74 -
Trigger Event:
release
-
Statement type: