nucel-agent-codex
Codex provider for the Nucel Agent SDK —
a subprocess wrapper for OpenAI's codex CLI.
Features
- JSONL event parsing — handles
thread.started,turn.started,item.completed,turn.completed,turn.failed, anderrorevents - Token tracking — input / output tokens from
turn.completed.token_usage - Budget enforcement — client-side cost guard before each query
- Sandbox + approval modes — maps
PermissionModeto the official--sandboxand--full-autoflags - Structured output — Codex supports JSON Schema responses
(capabilities:
structured_output: true) - Model selection —
--modelflag --skip-git-repo-check— works in arbitrary working directories
How it works
Each query spawns a fresh codex exec invocation:
Then parses the official JSONL event stream:
thread.started → turn.started → item.completed (agent_message, reasoning, …) → turn.completed
The provider extracts:
- Agent text from
item.completeditems whereitem.type == "agent_message" - Token usage from
turn.completed.token_usage.{input_tokens, output_tokens} - Errors from
turn.failed/errorevents
Reference: Codex CLI docs.
CLI flag mapping
SpawnConfig field |
CLI flag |
|---|---|
model |
--model |
permission_mode |
see sandbox table below |
env |
passed as subprocess environment |
| working dir | --cd <path> |
PermissionMode |
Codex flag(s) |
|---|---|
Prompt (default) |
--sandbox workspace-write |
AcceptEdits |
--full-auto |
BypassPermissions |
--dangerously-bypass-approvals-and-sandbox |
RejectAll |
--sandbox read-only |
Session resume
Codex CLI resume (codex exec resume) is not yet wired up — calling
resume() will log an info message and spawn a fresh session. Hence:
capabilities.session_resume = false
Usage
[]
= "0.1"
= { = "1", = ["full"] }
use ;
use Path;
async
Capabilities
session_resume: false (CLI resume not yet wired up)
token_usage: true
mcp_support: false
autonomous_mode: true
structured_output: true
Requirements
codexCLI on PATH:npm install -g @openai/codexOPENAI_API_KEY(also exported asCODEX_API_KEYforcodex execcompatibility)
Source
License
Apache-2.0