Overview
TheCodexSdkAdapter captures events from Codex SDK live runs, streaming them through the ingest pipeline in real-time.
Class: CodexSdkAdapter
Constructor
Ingest pipeline for event processing
Optional Codex SDK instance. If not provided, creates a new instance using
CODAPH_CODEX_PATH or CODEX_PATH environment variables.Methods
runAndCapture
Runs a Codex session and captures all events.Run configuration options
User prompt to send to agent
Working directory for the agent
Repository ID (auto-generated from cwd if not provided)
Model name to use
Thread ID to resume existing conversation
Callback invoked for each captured event
UUID for the capture session
Codex thread ID, or null if not available
Final agent message text, or null if not available
Supporting Types
CodexSdkAdapterInit
AdapterRunOptions
AdapterRunResult
Implementation Details
Event Flow
- Session initialization: Creates a new UUID session ID
- Prompt submission: Emits
prompt.submittedevent - Thread creation: Starts or resumes Codex thread
- Event streaming: Captures all thread events in real-time:
thread.started- Thread initializationitem.completed- Completed reasoning, messages, tool calls- Other Codex SDK events
- Error handling: Emits
errorevents on failure
Codex Path Resolution
The adapter resolves the Codex CLI path in the following order:CODAPH_CODEX_PATHenvironment variableCODEX_PATHenvironment variable- System PATH lookup using
which codex(Unix) orwhere codex(Windows)