codex-python 0.1.1__py3-none-any.whl → 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codex/__init__.py +12 -8
- codex/api.py +61 -133
- codex/config.py +82 -0
- codex/event.py +16 -0
- codex/native.py +56 -0
- codex/protocol/types.py +1719 -0
- {codex_python-0.1.1.dist-info → codex_python-0.2.0.dist-info}/METADATA +82 -17
- codex_python-0.2.0.dist-info/RECORD +11 -0
- codex_python-0.1.1.dist-info/RECORD +0 -7
- {codex_python-0.1.1.dist-info → codex_python-0.2.0.dist-info}/WHEEL +0 -0
- {codex_python-0.1.1.dist-info → codex_python-0.2.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: codex-python
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.2.0
|
4
4
|
Summary: A minimal Python library scaffold for codex-python
|
5
5
|
Project-URL: Homepage, https://github.com/gersmann/codex-python
|
6
6
|
Project-URL: Repository, https://github.com/gersmann/codex-python
|
@@ -36,15 +36,16 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
36
36
|
Classifier: Programming Language :: Python :: 3.13
|
37
37
|
Classifier: Typing :: Typed
|
38
38
|
Requires-Python: >=3.13
|
39
|
+
Requires-Dist: pydantic>=2.11.7
|
39
40
|
Description-Content-Type: text/markdown
|
40
41
|
|
41
42
|
# codex-python
|
42
43
|
|
43
|
-
|
44
|
+
Python interface to Codex, packaged as a single distribution (`codex-python`). Platform wheels include a native extension for in‑process execution. The library consolidates on native bindings (no subprocess wrapper).
|
44
45
|
|
45
46
|
## Quickstart
|
46
47
|
|
47
|
-
- Requires Python 3.
|
48
|
+
- Requires Python 3.12+.
|
48
49
|
- Package import name: `codex`.
|
49
50
|
- Distribution name (PyPI): `codex-python`.
|
50
51
|
|
@@ -55,30 +56,39 @@ A minimal Python library scaffold using `uv` with Python 3.13+.
|
|
55
56
|
|
56
57
|
## Usage
|
57
58
|
|
58
|
-
|
59
|
+
Native, non-interactive execution with Pydantic config:
|
59
60
|
|
60
61
|
```
|
61
|
-
from codex import run_exec
|
62
|
+
from codex.api import run_exec, CodexClient
|
63
|
+
from codex.config import CodexConfig, ApprovalPolicy, SandboxMode
|
62
64
|
|
63
|
-
|
64
|
-
|
65
|
-
|
65
|
+
cfg = CodexConfig(
|
66
|
+
model="gpt-5",
|
67
|
+
model_provider="openai",
|
68
|
+
approval_policy=ApprovalPolicy.ON_REQUEST,
|
69
|
+
sandbox_mode=SandboxMode.WORKSPACE_WRITE,
|
70
|
+
)
|
66
71
|
|
67
|
-
|
72
|
+
events = run_exec("explain this repo", config=cfg)
|
68
73
|
|
69
|
-
|
70
|
-
|
71
|
-
|
74
|
+
client = CodexClient(config=cfg)
|
75
|
+
for ev in client.start_conversation("add a smoke test"):
|
76
|
+
print(ev)
|
77
|
+
```
|
72
78
|
|
73
|
-
|
79
|
+
To stream raw dict events directly from the native layer:
|
74
80
|
|
75
81
|
```
|
76
|
-
from codex import
|
82
|
+
from codex.native import start_exec_stream
|
77
83
|
|
78
|
-
|
79
|
-
|
84
|
+
for e in start_exec_stream("explain this repo", config_overrides=cfg.to_dict()):
|
85
|
+
# each `e` is a dict representing an event envelope
|
86
|
+
print(e)
|
80
87
|
```
|
81
88
|
|
89
|
+
The event payload is typed: `Event.msg` is a union `EventMsg` from `codex.protocol.types`,
|
90
|
+
and is also exported at `codex.EventMsg` for convenience.
|
91
|
+
|
82
92
|
### Install uv
|
83
93
|
|
84
94
|
- macOS (Homebrew): `brew install uv`
|
@@ -125,6 +135,61 @@ uv publish --token "$PYPI_API_TOKEN"
|
|
125
135
|
- Format: `make fmt` (ruff formatter)
|
126
136
|
- Pre-commit: `uvx pre-commit install && uvx pre-commit run --all-files`
|
127
137
|
|
138
|
+
### Protocol bindings (from codex-rs)
|
139
|
+
|
140
|
+
- Prereq: Rust toolchain (`cargo`) installed.
|
141
|
+
- Generate Python types from the upstream protocol with:
|
142
|
+
|
143
|
+
```
|
144
|
+
make gen-protocol
|
145
|
+
```
|
146
|
+
|
147
|
+
This will:
|
148
|
+
- emit TypeScript types under `.generated/ts/`
|
149
|
+
- convert them to Python Pydantic models + Literal unions at `codex/protocol/types.py`
|
150
|
+
|
151
|
+
### Native bindings (PyO3)
|
152
|
+
|
153
|
+
- Install path
|
154
|
+
|
155
|
+
`pip install codex-python` installs a platform wheel that includes the native extension on supported platforms (Python 3.12/3.13; CI also attempts 3.14).
|
156
|
+
|
157
|
+
- Build locally (requires Rust + maturin):
|
158
|
+
|
159
|
+
```
|
160
|
+
make dev-native
|
161
|
+
```
|
162
|
+
|
163
|
+
- Notes:
|
164
|
+
- The native path embeds Codex directly; no subprocess.
|
165
|
+
- A helper `codex.native.preview_config(...)` returns a compact snapshot of the effective configuration (selected fields) for tests and introspection.
|
166
|
+
|
167
|
+
### Configuration (Pydantic)
|
168
|
+
|
169
|
+
Use the `CodexConfig` Pydantic model to pass overrides which mirror the Rust `ConfigOverrides`:
|
170
|
+
|
171
|
+
```
|
172
|
+
from codex.config import CodexConfig, ApprovalPolicy, SandboxMode
|
173
|
+
from codex.api import run_exec, CodexClient
|
174
|
+
|
175
|
+
cfg = CodexConfig(
|
176
|
+
model="gpt-5",
|
177
|
+
model_provider="openai",
|
178
|
+
approval_policy=ApprovalPolicy.ON_REQUEST,
|
179
|
+
sandbox_mode=SandboxMode.WORKSPACE_WRITE,
|
180
|
+
cwd="/path/to/project",
|
181
|
+
include_apply_patch_tool=True,
|
182
|
+
)
|
183
|
+
|
184
|
+
events = run_exec("Explain this project", config=cfg)
|
185
|
+
|
186
|
+
client = CodexClient(config=cfg)
|
187
|
+
for ev in client.start_conversation("Add a test for feature X"):
|
188
|
+
print(ev)
|
189
|
+
```
|
190
|
+
|
191
|
+
`CodexConfig.to_dict()` emits only set (non‑None) fields and serializes enums to their kebab‑case strings to match the native Rust types.
|
192
|
+
|
128
193
|
## Project Layout
|
129
194
|
|
130
195
|
```
|
@@ -142,4 +207,4 @@ Version is managed via `codex/__init__.py` and exposed as `__version__`. The bui
|
|
142
207
|
|
143
208
|
## Python Compatibility
|
144
209
|
|
145
|
-
-
|
210
|
+
- Supported: Python 3.12, 3.13. CI attempts 3.14 wheels when available.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
codex/__init__.py,sha256=xlyhxrsoviZDinInmCg1mHhybg5gFtxuuPKe4-WKp3w,606
|
2
|
+
codex/api.py,sha256=FhRSIAu5dpwTB4sO2qjuVjH_akFoDAG-2wyAyRSGCvw,2892
|
3
|
+
codex/config.py,sha256=388mrVtzyA6t8qigS8JxFSFPJbT3A-KMDMP-YQo6rUs,2869
|
4
|
+
codex/event.py,sha256=HPS6ySBa7Pwn4gRjQKj2yUE5_kiad4WFqwmA7aEdoiI,387
|
5
|
+
codex/native.py,sha256=ukaOK5U96oaJaY80sFSUSFNhRv1Wefix_8M-BCUat7A,2063
|
6
|
+
codex/protocol/types.py,sha256=YxnQBq5sgV_JC7E0q5Hkp8EIRcpvSTnBm1Uhv4Lc4Zs,38558
|
7
|
+
codex/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
8
|
+
codex_python-0.2.0.dist-info/METADATA,sha256=hLsX65ljGft-oPgvimWlDACHJAytrB1yjSxFW97fESw,6599
|
9
|
+
codex_python-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
10
|
+
codex_python-0.2.0.dist-info/licenses/LICENSE,sha256=ZhGahTKhsCbPWNmZ7ugZ14LVewMo4Gh1OeIOlQabyrI,1066
|
11
|
+
codex_python-0.2.0.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
codex/__init__.py,sha256=FsirGg1w3wP202sQMBOAOHkjglZU20dtRI6ZFLbN3z4,514
|
2
|
-
codex/api.py,sha256=aP1OcnMxSF-vJyxwVIllbydmrFiUESsuePvCyYkBXxo,4614
|
3
|
-
codex/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
4
|
-
codex_python-0.1.1.dist-info/METADATA,sha256=2_XGcNNm1g1q--mnoJSktrsdNo6IbZS3kcI0mcnXlcw,4351
|
5
|
-
codex_python-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
6
|
-
codex_python-0.1.1.dist-info/licenses/LICENSE,sha256=ZhGahTKhsCbPWNmZ7ugZ14LVewMo4Gh1OeIOlQabyrI,1066
|
7
|
-
codex_python-0.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|