Skip to main content

Run the Codex CLI non-interactively from Python, backed by a Rust core.

Project description

codexcw (Python)

Run the Codex CLI non-interactively from Python, backed by a Rust core. It spawns codex exec --json, decodes the JSONL event stream, and exposes each run as iterables, callbacks, results, and typed errors.

The codex executable must be on PATH, authenticated, and new enough to support codex exec --json. Defaults are automation-friendly: read-only sandbox, approval never, ephemeral sessions, color disabled, git check skipped.

Install

pip install codexcw

Usage

from codexcw import Runner, Request

runner = Runner()
result = runner.run(Request(prompt="diga oi"))
print(result.final_message)

Streaming

from codexcw import Runner, Request

runner = Runner()
session = runner.start(Request(prompt="resuma este repo"))
for event in session.events():
    if event.type == "item.completed" and event.item.type == "agent_message":
        print(event.item.text)
result = session.wait()

Account usage

from codexcw import AccountUsageRequest, get_account_usage

usage = get_account_usage(AccountUsageRequest(env={"CODEX_HOME": "/tmp/codex-home"}))
print(usage.rate_limits.primary.used_percent if usage.rate_limits.primary else None)
print(usage.token_usage.summary.lifetime_tokens if usage.token_usage else None)

Running many Codex instances

from codexcw import Runner, Request

runner = Runner()
group = runner.run_many(
    [Request(prompt="review package A"), Request(prompt="review package B")],
    max_concurrent=2,
)
for run_event in group.events():
    print(run_event.index, run_event.event.type)
results = group.wait()

Async

import asyncio
from codexcw import Request
from codexcw.aio import Runner

async def main():
    runner = Runner()
    session = await runner.start(Request(prompt="oi"))
    async for event in session.events():
        print(event.type)
    result = await session.wait()
    print(result.final_message)

asyncio.run(main())

License

CC0 1.0 Universal.

Project details


Download files

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

Source Distribution

codexcw-0.2.3.tar.gz (57.7 kB view details)

Uploaded Source

Built Distributions

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

codexcw-0.2.3-cp39-abi3-win_amd64.whl (741.6 kB view details)

Uploaded CPython 3.9+Windows x86-64

codexcw-0.2.3-cp39-abi3-musllinux_1_1_x86_64.whl (979.4 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.1+ x86-64

codexcw-0.2.3-cp39-abi3-musllinux_1_1_aarch64.whl (919.9 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.1+ ARM64

codexcw-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (767.7 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

codexcw-0.2.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (743.8 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

codexcw-0.2.3-cp39-abi3-macosx_11_0_arm64.whl (701.1 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

codexcw-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl (727.5 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file codexcw-0.2.3.tar.gz.

File metadata

  • Download URL: codexcw-0.2.3.tar.gz
  • Upload date:
  • Size: 57.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codexcw-0.2.3.tar.gz
Algorithm Hash digest
SHA256 29f4b87916a652b6ebb72188f6d069ffd704724c26a6bae00916fb9b9e504186
MD5 ad45e1848b90add9bfd926daf947c440
BLAKE2b-256 9c42752c38edfb0e3389753f287d1da504f8be152bba85357013ac4f7ebc68e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.3.tar.gz:

Publisher: release-pypi.yml on c3-oss/codexcw

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

File details

Details for the file codexcw-0.2.3-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: codexcw-0.2.3-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 741.6 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codexcw-0.2.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 52e7aec24654f8f8018a35ab71260c319a10fc4dfdf3b72f6e5a234b222c358a
MD5 c162e5797fa75dea29ac3733725e1ec7
BLAKE2b-256 cbbbbd2b3b2b101d17b26b25bc32b3523dc4bc9b35e3b7e038afbaddf2721f1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.3-cp39-abi3-win_amd64.whl:

Publisher: release-pypi.yml on c3-oss/codexcw

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

File details

Details for the file codexcw-0.2.3-cp39-abi3-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for codexcw-0.2.3-cp39-abi3-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 e1ef8f387a0684681509fefc799075f6396fbab54fee7cbe9b53ff48f411fd6f
MD5 796b9375470823a5d506ed4317874ea6
BLAKE2b-256 a2a3cd2c90a639f276450587011a7bb5e3bb2c13adf007d87eb19f678944fb03

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.3-cp39-abi3-musllinux_1_1_x86_64.whl:

Publisher: release-pypi.yml on c3-oss/codexcw

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

File details

Details for the file codexcw-0.2.3-cp39-abi3-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for codexcw-0.2.3-cp39-abi3-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 51202dbb7de7296df8e51078d353b983be396855ddc3aec93de6a69d5464322f
MD5 95c8d471e4898d9044293e6a809cdb63
BLAKE2b-256 5b3230dc26d59a234a46b2422990c364c22bac0cbd9ffbec07f9aaaf96554f17

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.3-cp39-abi3-musllinux_1_1_aarch64.whl:

Publisher: release-pypi.yml on c3-oss/codexcw

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

File details

Details for the file codexcw-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for codexcw-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 335784cf66ae14dd484a900048516089ccafce39b8d8f49419463a532ec4707d
MD5 2d2f54c306bd220503a243540aa05828
BLAKE2b-256 c0a7730deab796ef7f6ddf13a9ac457db3f92b2d022ca7bb726088d69a5e841d

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-pypi.yml on c3-oss/codexcw

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

File details

Details for the file codexcw-0.2.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for codexcw-0.2.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3f1aa928d5e71c29fd2d884740a0b7eb94b3ceefe59fe3f6b6e82ea66e3a1be4
MD5 7fed3694ff836f9061b5f6ac64c0bb46
BLAKE2b-256 90a31078abcf233ced0290339bb4a2f9520fecf442b5ad0ed0a491f1a701647f

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-pypi.yml on c3-oss/codexcw

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

File details

Details for the file codexcw-0.2.3-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for codexcw-0.2.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9571eaa51a10326e88258aac33b1e5443be27daf485700bd7872c0f3fe585e17
MD5 f0a66b5178642637b434b6fab315f1d8
BLAKE2b-256 63b22b2939131dfab8b3311e22008a279b3f44e6f303c92852b81c61601f79ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.3-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release-pypi.yml on c3-oss/codexcw

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

File details

Details for the file codexcw-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for codexcw-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ede92b068f35715f9c6f3978e0b22e94b51b0ec096c2ab001f07890af5470b2f
MD5 b4e5b65109001da57aacc76e7350cd1c
BLAKE2b-256 d3b2cbeb4abd0a01bb99015c1a1348cd4959673fbd73f63cbbc022c930211825

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release-pypi.yml on c3-oss/codexcw

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page