Skip to content

Commit 8ef0d8a

Browse files
committed
feat: 1.0b2
1 parent 74b95c1 commit 8ef0d8a

13 files changed

Lines changed: 720 additions & 43 deletions

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,38 @@ jobs:
4242

4343
- name: Test
4444
run: make test
45+
46+
- name: Detect integration test availability
47+
id: integration
48+
env:
49+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
50+
run: |
51+
if [ -n "${OPENAI_API_KEY:-}" ]; then
52+
echo "enabled=true" >> "$GITHUB_OUTPUT"
53+
else
54+
echo "enabled=false" >> "$GITHUB_OUTPUT"
55+
fi
56+
57+
- name: Install integration test dependencies
58+
if: ${{ steps.integration.outputs.enabled == 'true' }}
59+
run: pip install zstandard
60+
61+
- name: Fetch bundled codex binary for integration test
62+
if: ${{ steps.integration.outputs.enabled == 'true' }}
63+
env:
64+
CODEX_BINARY_RELEASE_TAG: ${{ vars.CODEX_BINARY_RELEASE_TAG || 'latest' }}
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
run: |
67+
set -euo pipefail
68+
python scripts/fetch_codex_binary.py \
69+
--release-tag "$CODEX_BINARY_RELEASE_TAG" \
70+
--target-triple x86_64-unknown-linux-musl
71+
test -f codex/vendor/x86_64-unknown-linux-musl/codex/codex
72+
73+
- name: Integration test (real codex binary)
74+
if: ${{ steps.integration.outputs.enabled == 'true' }}
75+
env:
76+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
77+
CODEX_BINARY_PATH: codex/vendor/x86_64-unknown-linux-musl/codex/codex
78+
CODEX_INTEGRATION_TEST: "1"
79+
run: uv run --group dev pytest -q tests/test_integration_real_binary.py

.github/workflows/release-published.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
tag: ${{ steps.ctx.outputs.tag }}
2121
version: ${{ steps.resolve.outputs.version }}
2222
sha: ${{ steps.ctx.outputs.sha }}
23+
build_sha: ${{ steps.build_sha.outputs.sha }}
2324
steps:
2425
- name: Checkout
2526
uses: actions/checkout@v4
@@ -154,6 +155,15 @@ jobs:
154155
});
155156
core.info(`Updated release ${rel.id} to tag ${realTag}`);
156157
158+
- name: Resolve build SHA
159+
id: build_sha
160+
shell: bash
161+
run: |
162+
set -euo pipefail
163+
SHA=$(git rev-parse HEAD)
164+
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
165+
echo "Using build SHA: $SHA"
166+
157167
build-wheels:
158168
name: Build native wheels
159169
needs: prepare
@@ -205,6 +215,7 @@ jobs:
205215
uses: actions/checkout@v4
206216
with:
207217
fetch-depth: 0
218+
ref: ${{ needs.prepare.outputs.build_sha }}
208219

209220
- name: Set up Rust
210221
uses: dtolnay/rust-toolchain@stable
@@ -345,6 +356,8 @@ jobs:
345356
steps:
346357
- name: Checkout repository
347358
uses: actions/checkout@v4
359+
with:
360+
ref: ${{ needs.prepare.outputs.build_sha }}
348361

349362
- name: Set up Rust
350363
uses: dtolnay/rust-toolchain@stable

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,27 @@ thread.run("Continue from previous context")
8888

8989
## Options
9090

91-
- `CodexOptions`: `codex_path_override`, `base_url`, `api_key`
92-
- `ThreadOptions`: `model`, `sandbox_mode`, `working_directory`, `skip_git_repo_check`
93-
- `TurnOptions`: `output_schema`
91+
- `CodexOptions`: `codex_path_override`, `base_url`, `api_key`, `config`, `env`
92+
- `ThreadOptions`: `model`, `sandbox_mode`, `working_directory`, `skip_git_repo_check`, `model_reasoning_effort`, `network_access_enabled`, `web_search_mode`, `web_search_enabled`, `approval_policy`, `additional_directories`
93+
- `TurnOptions`: `output_schema`, `signal`
94+
95+
## Cancellation
96+
97+
```python
98+
import threading
99+
100+
from codex import Codex, TurnOptions
101+
102+
cancel = threading.Event()
103+
104+
client = Codex()
105+
thread = client.start_thread()
106+
stream = thread.run_streamed("Long running task", TurnOptions(signal=cancel))
107+
108+
cancel.set()
109+
for event in stream.events:
110+
print(event)
111+
```
94112

95113
## Bundled binary behavior
96114

codex/__init__.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@
2626
TodoListItem,
2727
WebSearchItem,
2828
)
29-
from codex.options import ApprovalMode, CodexOptions, SandboxMode, ThreadOptions, TurnOptions
29+
from codex.options import (
30+
ApprovalMode,
31+
CancelSignal,
32+
CodexConfigObject,
33+
CodexConfigValue,
34+
CodexOptions,
35+
ModelReasoningEffort,
36+
SandboxMode,
37+
ThreadOptions,
38+
TurnOptions,
39+
WebSearchMode,
40+
)
3041
from codex.thread import Input, RunResult, RunStreamedResult, Thread, UserInput
3142

3243
__version__ = "1.0.0"
@@ -47,6 +58,11 @@
4758
"TurnOptions",
4859
"ApprovalMode",
4960
"SandboxMode",
61+
"ModelReasoningEffort",
62+
"WebSearchMode",
63+
"CodexConfigValue",
64+
"CodexConfigObject",
65+
"CancelSignal",
5066
"ThreadEvent",
5167
"ThreadStartedEvent",
5268
"TurnStartedEvent",

codex/codex.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ class Codex:
1010

1111
def __init__(self, options: CodexOptions | None = None) -> None:
1212
resolved = options or CodexOptions()
13-
self._exec = CodexExec(resolved.codex_path_override)
13+
self._exec = CodexExec(
14+
resolved.codex_path_override,
15+
env_override=resolved.env,
16+
config_overrides=resolved.config,
17+
)
1418
self._options = resolved
1519

1620
def start_thread(self, options: ThreadOptions | None = None) -> Thread:

0 commit comments

Comments
 (0)