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.1.tar.gz (55.4 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.1-cp39-abi3-win_amd64.whl (716.1 kB view details)

Uploaded CPython 3.9+Windows x86-64

codexcw-0.2.1-cp39-abi3-musllinux_1_1_x86_64.whl (961.1 kB view details)

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

codexcw-0.2.1-cp39-abi3-musllinux_1_1_aarch64.whl (898.3 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.1+ ARM64

codexcw-0.2.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (748.6 kB view details)

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

codexcw-0.2.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (720.2 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

codexcw-0.2.1-cp39-abi3-macosx_11_0_arm64.whl (680.7 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

codexcw-0.2.1-cp39-abi3-macosx_10_12_x86_64.whl (709.6 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: codexcw-0.2.1.tar.gz
  • Upload date:
  • Size: 55.4 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.1.tar.gz
Algorithm Hash digest
SHA256 f0af1257c13cfcbcabc1529a9856cc9d0d4b8caa5a749cdc72046276499d02f4
MD5 dcc08357ee2e7cdc854edb9c4b96d2ac
BLAKE2b-256 45c5373ff26eee0cd387bc135e7354e3bce0b72b477ff1141000f43c80842a28

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.1.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.1-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: codexcw-0.2.1-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 716.1 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.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 da2ca51eef176863f217d6112a1369ea06399f52a09b14f291c28181be7cc8fd
MD5 4f040a98dd8d2a1e7f043cf24f10925d
BLAKE2b-256 f4792a1695567dcad1583469cd3fc908a847ceac477e2b265c7cbb8ce5b296fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.1-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.1-cp39-abi3-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for codexcw-0.2.1-cp39-abi3-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 8f8003c205cc2ea9727f895a5cfccc13e74544ba994498e56a1c962902762d06
MD5 7196e5bded701fa31f647fe85ed461fb
BLAKE2b-256 d387292724730b35697f58a7ce2c2357b7b8f1d0f76d088ccfea67a9c313de55

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.1-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.1-cp39-abi3-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for codexcw-0.2.1-cp39-abi3-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 b14c7a09d278a75decb363db7417df43d16b999069744ed8ba5351ab1573e96f
MD5 42bdf84bd11bef15818dd02161559704
BLAKE2b-256 9dd7b80d72ce9d7b09933c032e60ad8dbaa810415fb288d61af884b9e41af778

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.1-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.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for codexcw-0.2.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b03c7b139083ddd61b2384bb6dd52a143a981936db8bb5cd19ae666b2c72b0a8
MD5 292b930ceab9180f16f1e10ddcc15145
BLAKE2b-256 6d4747eff8e8781317b1f0314c377958df55ca2df79298dd97ad8e8230fe5ed0

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.1-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.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for codexcw-0.2.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f167a355a4e1f529d8edc94137c7b3c0518eaca9a6b4d7da6ca68b9d2d6b1614
MD5 7e6590ff80cf05f06de53978ef889f4b
BLAKE2b-256 cd9764bbd8a3201f931e0c1c0753495a04527625c7e734709d4d7416daf9148a

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.1-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.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for codexcw-0.2.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c4a643dacba86fbabd575a2048b04e622806c23f6c30135c4b36715cd2ea1880
MD5 67a399c018f6c6874a0d93e7469c6224
BLAKE2b-256 c90f280bfe239cd0f5f832348d12097317554aa407c36e15d755bcbbb9e1757b

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.1-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.1-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for codexcw-0.2.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a1131f6e1c9321ffc3706c68e71eb5c8a7e9a3c0bfb6ba620956f95a42334ab5
MD5 6cf2492d01959987c0dc9b989e8ff094
BLAKE2b-256 62562ab55a8c630ea7811e52e4b15f22755a60104215e3a3e1c253f4ea209410

See more details on using hashes here.

Provenance

The following attestation bundles were made for codexcw-0.2.1-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