Skip to content

exec: one-shot codex exec runs in a private CODEX_HOME; auth: may_refresh, refresh_lock - #2

Merged
macalinao merged 2 commits into
mainfrom
exec
Nov 6, 2026
Merged

macalinao merged 2 commits into
mainfrom
exec

Conversation

@macalinao

Copy link
Copy Markdown
Contributor

Moves the Codex CLI runner out of a downstream image-generation tool into codexwire (macalinao/tala-agent#889), so callers keep only their own glue.

  • exec::Exec::run: codex exec --json in a fresh 0700 run dir (home/ = the run's CODEX_HOME with only a copy of auth.json, work/, refs/ for --image inputs); prompt on stdin; timeout with a bounded wait for the pipes after a kill; the parent's allowlisted env (client::child_env) plus the caller's, HOME/CODEX_HOME/TMPDIR forced to the run's. Refreshed tokens are copied back (auth::copy_back's rule, serialised in-process). The Run removes its dir on drop or remove().await.
  • exec::failure: why a run failed, from its --json events and log: LoginDead (spent/revoked refresh token), LoginRefused (401), Said (the turn's failure or last error, retry notices skipped).
  • exec::image_prompt, Run::generated_images: for image generation (<CODEX_HOME>/generated_images/, regular files only, oldest first, size-capped).
  • auth::may_refresh (access token within 10 min of expiry, or last refresh a week old, or unreadable) and auth::refresh_lock: runs that may spend the single-use refresh token go alone.

New deps: base64, chrono (no default features), tokio time.

Tests: unit tests for may_refresh, failure, image_prompt, argv/env, file collection; tests/exec.rs runs a fake codex (sh) for the private home, image in/out, copy-back, failure, timeout and missing login. Locally: clippy -D warnings, cargo test --all-targets --locked (lib 18, spawn 2, exec 4, corpus 1, doctest 1), docs -D warnings, check-codegen, fmt.

Paolo Santos added 2 commits November 6, 2026 23:32
…resh, refresh_lock

exec::Exec::run copies the login into a fresh 0700 CODEX_HOME, runs
`codex exec --json` with the prompt on stdin and the images attached,
copies refreshed tokens back (serialised in-process), and removes the run
dir when the Run is dropped. exec::failure reads why a run failed (a dead
ChatGPT login, a 401, the turn's error); image_prompt and
Run::generated_images serve image generation.

auth::may_refresh says when a run may refresh the single-use refresh
token, and refresh_lock lets such a run go alone.
@macalinao
macalinao merged commit a153f3f into main Nov 6, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant