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.0.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.0-cp39-abi3-win_amd64.whl (718.9 kB view details)

Uploaded CPython 3.9+Windows x86-64

codexcw-0.2.0-cp39-abi3-musllinux_1_1_x86_64.whl (960.9 kB view details)

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

codexcw-0.2.0-cp39-abi3-musllinux_1_1_aarch64.whl (898.4 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.1+ ARM64

codexcw-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (748.1 kB view details)

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

codexcw-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (720.1 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

codexcw-0.2.0-cp39-abi3-macosx_11_0_arm64.whl (681.3 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

codexcw-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl (709.2 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: codexcw-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 e4839240ee11045abc86332a337970d9c44376de1720803d58f37dfff4d5bbd7
MD5 10188f7104d26edf51f66da9f72efd56
BLAKE2b-256 f4b950496162a69dc3a75cf73d043ba5e3307795c2d55fcc8a7fb597a4b467f2

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: codexcw-0.2.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 718.9 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.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 cdd37dff15d6b479abff6fd7af49654fe0e79cf9fe09de0ad4a66bae859627b8
MD5 f468cde12eb4320815f886a1251c5ce3
BLAKE2b-256 4b49152732eab4252b0506544963dc6201f8f6d8141ee72870ed5d151a77c020

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for codexcw-0.2.0-cp39-abi3-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 61c92c5b86ff3949dd401e05aef88ca97426d2ea3e2cdb36c8d7e46820d8316b
MD5 e4527b8cd5a3d4cfee4b35e857639ec3
BLAKE2b-256 b5784dbe0e7d240bbae2818032b2ad9e8b3e247378c5d7a729c4ba4f39e483ca

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for codexcw-0.2.0-cp39-abi3-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 ef0d7fd32f6242999654cd171006b54776c8a2e773a69a166401e81381be3038
MD5 288fc9023b7c9351e7688c7f048e7cb1
BLAKE2b-256 8b1e5f730f10fea3cc68935da6922838a198e6eec978dcb10e2fae183838ed11

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for codexcw-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 202b49da2aa8dc3b7236521414ad4f24b7caa752d278659a96825c71979cc6ab
MD5 ee537279a8dfc730d915c50a9c92a7aa
BLAKE2b-256 c96c6aa6de6c1a2960a392875ec05abe96f17092e227226faf4204e43e6bfb62

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for codexcw-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 80dee3ded43cfee07e886f98804833ed71364012c29a119db55d6d037bd944c3
MD5 76f5f10d6f654060b724f3463aab085d
BLAKE2b-256 4db3225a0ee4ecbc7cba66432fb43bfc7a0f272741ecb2be52e2d29928032b01

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for codexcw-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9679f1d9b0b2c0cbd8af6b0658eb683f3afb651134c4e060055b5b694bf552c7
MD5 9e3597b0186117541d4b142d461a6b0b
BLAKE2b-256 38783464314f288f4d7a5b7e9066020f0fd3a5517cbf78fa1f9f6efb4dbe19d8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for codexcw-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9d073b84b0034adccbfdf3edb6083060ada188eb36d1e26b4a61f25fe8df0736
MD5 7d68d25bc3c257ff53e0c38b212419ba
BLAKE2b-256 2243e3fec7dd098a4df4f5150aff21adcb21514c0b18b79a8ccd49dc9afdecd5

See more details on using hashes here.

Provenance

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