Documentation
¶
Overview ¶
Package codex reads `codex exec --json` runs.
The stream reports usage once, at turn.completed, as a running total for the thread, and one prompt is one turn. So the budget is watched in the rollout file Codex writes during the turn, which also gives per-request rows. The stream stays as the check on the file and as the record when it cannot be read.
Index ¶
Constants ¶
const ( // UnknownModel stands in when neither the command nor the config names // a model. It prices at the catalog's fallback tier. UnknownModel = "unknown" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct{}
Agent is the Codex CLI.
func (Agent) NewSession ¶
NewSession starts reading a run of the planned command.
func (Agent) Plan ¶
Plan adds --json. Codex has no budget flag, so the wrapper watches the rollout file, and a run that writes none has nothing holding it to the budget.
func (Agent) ReadHome ¶
ReadHome reads a Codex run that already ended from the Codex home it wrote to: every rollout file under sessions/, the run's own threads and their subagents alike, each read as the wrapper reads a rollout file. The home must be one made for the job, as codex-action's codex-home input makes one. A file last written before since belongs to an earlier job and is not read; a file started before since and written after it holds an earlier job's spend, so the reading is refused. A zero since reads every file.
Costroid did not start this run, so no budget held it: the grade is none. The files do not say how the run billed, but openai/codex-action runs Codex only on an API key, its openai-api-key input, so the rows read measured.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session reads one Codex run. Feed and Tail run on separate goroutines, so the lock covers everything below it.
func (*Session) Feed ¶
Feed reads one stdout line. Its type is read first, then the fields that type carries, so a field this reader never uses, such as message, can take any shape. A line whose shape this reader does not know is skipped and counted. A turn.completed line that cannot be read stops the run's reading at Finish, because it holds the run's figures.
func (*Session) Finish ¶
Finish returns the run's usage and the grade it earned. Per-request rows from the rollout files stand unless the stream's total contradicts them. A run with neither source reported nothing, and whatever it spent is unknown.