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.2.tar.gz (57.5 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.2-cp39-abi3-win_amd64.whl (742.2 kB view details)

Uploaded CPython 3.9+Windows x86-64

codexcw-0.2.2-cp39-abi3-musllinux_1_1_x86_64.whl (979.8 kB view details)

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

codexcw-0.2.2-cp39-abi3-musllinux_1_1_aarch64.whl (918.3 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.1+ ARM64

codexcw-0.2.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (766.2 kB view details)

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

codexcw-0.2.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (742.3 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

codexcw-0.2.2-cp39-abi3-macosx_11_0_arm64.whl (701.3 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

codexcw-0.2.2-cp39-abi3-macosx_10_12_x86_64.whl (726.1 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: codexcw-0.2.2.tar.gz
  • Upload date:
  • Size: 57.5 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.2.tar.gz
Algorithm Hash digest
SHA256 95a7dbffd4c7cf07828a893b29b7868133ff9fdaedf99d59e7ad1b875d9d8af6
MD5 8412a6b3260accc19c2988e6ab9ebf23
BLAKE2b-256 42ff414cef5ad7be8f47281deb393aac2daf374c051fafebd92bdb42fee21a8b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: codexcw-0.2.2-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 742.2 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.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d3ec21c855d8ddc86461201def97e5b635912c5054ba74021363527909556a8b
MD5 a30fd44d9bac01a21cea230365e7cd1d
BLAKE2b-256 2c8143fe886e2009dcccc30c749d01706d75c50f579b5d093459c703c48df80a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for codexcw-0.2.2-cp39-abi3-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 f9020599b4fb30d6ba79da2d499af116da3c47ab5fc13dec8a6837a129b57d32
MD5 ded9dfbcf7b5626cef73d778a828bbed
BLAKE2b-256 72b8927544a912df0006a970fc2a5b2cace8a2082e1eba78c6b5b5fd6d56f30c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for codexcw-0.2.2-cp39-abi3-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 39fe5c7a3d5e50e1847fc2c22fe0493772e2363952a9dc6871105ba9aec2b805
MD5 3b3ee7ba93cf796bf44eada679bd9cda
BLAKE2b-256 4402dc621b5c061a90b3a89a641f7574a6a67b51fac0a2adf0b263ec4bc03b63

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for codexcw-0.2.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b5e0fb86427130d9ab3cfca49352df2988c14e2b36838efacd84c137d6dc2d0d
MD5 9b947bb958a8c65c51ab52a7f77e3338
BLAKE2b-256 1cbcd506fe2980c2160b7e6b35e1ee36456f91258f714c7a57a23f0aa29fe360

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for codexcw-0.2.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 511939580fa9b19d15a6391c52246a2b54cb0c455daf8dc4416b70ee0c0cdf17
MD5 b06b62f021109ead533ca358f53fd50e
BLAKE2b-256 deedb8c376585ca2f21efda1f25047ca685fdbf3a3ee788efdd1110fc0367ec6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for codexcw-0.2.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 19139ebb781106e7fe76c267f1b2bd80489e56dd4320833f4bbee7297238d2c1
MD5 af0f317b724f7c162787eeebe104ccd2
BLAKE2b-256 47cf3d96e918f5a6bcaaffd0c55899d7944d4ca3c54bd7c27aed2394bcce3080

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for codexcw-0.2.2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c890994b629334cb505adb0c024baec22d53cc9db575d589481f02f2546150e5
MD5 2cb89529ebd1471b0d7d96c6d2aa8ce1
BLAKE2b-256 4e9e141d46dfa9def767d223d6d37819f3598d1a4465fb50ee3a5d0bb9e0eb70

See more details on using hashes here.

Provenance

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