Skip to content

Commit 5df3b08

Browse files
committed
fix(protocol): relax Pydantic models (extra=ignore) to accept intersection fields in EventMsg; Makefile uses 'codex generate-types' when available
1 parent e43b328 commit 5df3b08

5 files changed

Lines changed: 212 additions & 188 deletions

File tree

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ clean:
5454
gen-protocol:
5555
@echo "Generating TypeScript protocol types via codex-proj/codex-rs ..."
5656
@mkdir -p .generated/ts
57-
@cd codex-proj/codex-rs && cargo run -p codex-protocol-ts -- --out ../../.generated/ts
57+
@if command -v codex >/dev/null 2>&1; then \
58+
echo "Using 'codex generate-types'"; \
59+
codex generate-types --out .generated/ts; \
60+
else \
61+
echo "Using cargo run -p codex-protocol-ts"; \
62+
cd codex-proj/codex-rs && cargo run -p codex-protocol-ts -- --out ../../.generated/ts; \
63+
fi
5864
@echo "Generating Python bindings ..."
5965
@python3 scripts/generate_protocol_py.py .generated/ts
6066
@$(MAKE) fmt

codex/api.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ def run_exec(
5151
prompt: str,
5252
*,
5353
model: str | None = None,
54+
oss: bool = False,
5455
full_auto: bool = False,
5556
cd: str | None = None,
57+
skip_git_repo_check: bool = False,
5658
timeout: float | None = None,
5759
env: Mapping[str, str] | None = None,
5860
executable: str = "codex",
@@ -73,8 +75,12 @@ def run_exec(
7375
cmd.extend(["--cd", cd])
7476
if model:
7577
cmd.extend(["-m", model])
78+
if oss:
79+
cmd.append("--oss")
7680
if full_auto:
7781
cmd.append("--full-auto")
82+
if skip_git_repo_check:
83+
cmd.append("--skip-git-repo-check")
7884
if extra_args:
7985
cmd.extend(list(extra_args))
8086

@@ -127,8 +133,10 @@ def run(
127133
prompt: str,
128134
*,
129135
model: str | None = None,
136+
oss: bool | None = None,
130137
full_auto: bool | None = None,
131138
cd: str | None = None,
139+
skip_git_repo_check: bool | None = None,
132140
timeout: float | None = None,
133141
env: Mapping[str, str] | None = None,
134142
extra_args: Iterable[str] | None = None,
@@ -140,6 +148,8 @@ def run(
140148
eff_model = model if model is not None else self.model
141149
eff_full_auto = full_auto if full_auto is not None else self.full_auto
142150
eff_cd = cd if cd is not None else self.cd
151+
eff_oss = bool(oss) if oss is not None else False
152+
eff_skip_git = bool(skip_git_repo_check) if skip_git_repo_check is not None else False
143153

144154
# Merge environment overlays; run_exec will merge with os.environ
145155
merged_env: Mapping[str, str] | None
@@ -160,8 +170,10 @@ def run(
160170
return run_exec(
161171
prompt,
162172
model=eff_model,
173+
oss=eff_oss,
163174
full_auto=eff_full_auto,
164175
cd=eff_cd,
176+
skip_git_repo_check=eff_skip_git,
165177
timeout=timeout,
166178
env=merged_env,
167179
executable=self.executable,

codex/protocol/runtime.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ def stream_exec_events(
2222
*,
2323
executable: str = "codex",
2424
model: str | None = None,
25+
oss: bool = False,
2526
full_auto: bool = False,
2627
cd: str | None = None,
28+
skip_git_repo_check: bool = False,
2729
env: dict[str, str] | None = None,
2830
) -> Iterator[Event]:
2931
"""Spawn `codex exec --json` and yield Event objects from NDJSON stdout.
@@ -35,8 +37,12 @@ def stream_exec_events(
3537
cmd += ["--cd", cd]
3638
if model:
3739
cmd += ["-m", model]
40+
if oss:
41+
cmd.append("--oss")
3842
if full_auto:
3943
cmd.append("--full-auto")
44+
if skip_git_repo_check:
45+
cmd.append("--skip-git-repo-check")
4046
cmd += ["exec", "--json", prompt]
4147

4248
with subprocess.Popen(

0 commit comments

Comments
 (0)