Expand description
Domain types shared across commands: enums for CLI options, version parsing, and structured JSONL events.
§JSONL schema: what is verified and what is assumed
This parser was rewritten in #73 after the previous one was found to match an event shape the CLI never emits. It matched a fixture that invented the schema, so every test passed while real output produced empty results. The split below exists so the next person can check the assumptions instead of rediscovering the bug.
Verified against codex-cli 0.145.0, from the compiled serde tag list
and live runs of both codex exec --json and codex exec review --json:
-
The event vocabulary is
thread.started,turn.started,turn.completed,turn.failed,item.started,item.updated,item.completed. There is no barecompleted. Review emits the same vocabulary as exec. -
thread.startedcarriesthread_id. -
A completed turn reports token counts, never a monetary cost. The
usageobject carriesinput_tokens,cached_input_tokens,cache_write_input_tokens,output_tokens, andreasoning_output_tokens. It does not carrytotal_tokens, soTokenUsage::totalreaches a total through its input plus output fallback on every real run. -
Assistant text arrives as an
item.completedevent whoseitemhas atypeofagent_messageand its text in atextfield. A review’s diff-reading steps arrive ascommand_executionitems on the same event. -
A review’s
turn.completedreports a usage object of all zeros. -
Exhausting the native rollout budget emits an
errorevent followed byturn.failed, both withshared rollout token budget exhausted. The terminal event carries no usage object on 0.145.0 even though Codex used its internal meter to make the decision. -
The stream carries no incremental text. Three captured runs, a one-word exec, a four-sentence exec, and a review, each delivered the whole assistant message in a single
item.completed. Noitem.updated, no partial or delta fields, andcodex exec --helphas no flag that changes output granularity. There is nothing to assemble, which is why this module has no equivalent ofclaude-wrapper’sPartialMessageEvent(#84).
Assumed, still: nothing load-bearing.
JsonLineEvent::agent_message_text also accepts an item_type
discriminator and a content block array, neither of which has been seen
in real output. That tolerance stays because the failure mode when this
parser guesses wrong is an empty result rather than an error, which is how
#73 went unnoticed.
To re-confirm after a CLI upgrade, capture a run and check result is
non-empty:
codex exec --json --ephemeral --skip-git-repo-check "reply with: ok" > turn.jsonlStructs§
- CliVersion
- Parsed semantic version of the Codex CLI (
major.minor.patch). - Command
Execution - A shell command the model ran, from a
command_executionitem. - Json
Line Event - A single parsed JSONL event from
--jsonoutput. - Query
Result - A typed summary of a completed
codex execrun, assembled from the JSONL event stream. - Token
Usage - Token counts reported on a completed turn.
- Version
Parse Error
Enums§
- Approval
Policy - When the model should ask for human approval before executing commands.
- Approval
Policy Config - Approval policy values accepted by the
approval_policyconfig key. - CliVersion
Status - Classification of an installed CLI version against a tested range.
- Color
- Color output mode for exec commands.
- Sandbox
Mode - Sandbox policy for model-generated shell commands.
- Turn
Failure Kind - A terminal
turn.failedclassification from the Codex JSONL stream. - WebSearch
Mode - Web search mode, set through the
web_searchconfig key.