Documentation
¶
Overview ¶
Package codex provides the Agent implementation for OpenAI's `codex` CLI. Registration happens in init() — any binary that links this package will have "codex" available in the agent registry.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCommand ¶
BuildCommand builds the codex CLI command string.
agentSessionID is the codex thread UUID (Session.AgentSessionID). On resume:
- if non-empty: `codex resume <id>` (positional)
- if empty: `codex resume --last`
In both resume branches the command falls back to a fresh `codex` on non-zero exit — better to land in a usable state than strand the user when the prior session can't be resumed. Crashes, auth failures, or Ctrl-C will also trigger the fallback; that's intentional.
envExports, when non-empty, is prepended verbatim as a shell prelude. It comes from <agent>-env.json via the caller — for codex this lets the user set provider keys or PATH bits that need to be visible to codex's early startup, too early for codex's own config.toml shell policy to take effect.
func DiscoverSessionID ¶
DiscoverSessionID polls ~/.codex/sessions/ for a rollout file whose mtime is at or after spawnStart and returns its UUID. Empty + false on timeout, missing sessions dir, or any I/O error along the way — callers fall back to `codex resume --last` semantics, which is strictly less precise but still correct.
Implementation: scan the day-directory matching spawnStart's UTC date (plus the previous day if spawnStart is within the first 5 minutes of UTC midnight, to absorb clock skew). The file whose mtime is closest to spawnStart and >= spawnStart wins.
func FindCodexChild ¶
FindCodexChild finds a codex process among children of the given PID by walking /proc/*/status. Pure Go — no pgrep dependency.
func IsCodexAlive ¶
IsCodexAlive checks if a PID exists and is not a zombie.
Types ¶
This section is empty.