Documentation
¶
Overview ¶
Package codex adapts the OpenAI Codex CLI (`codex`) to codexmon's agent contract: it locates the binary, injects the `exec --json` / `--output-last-message` flags that make a run observable, and parses codex's JSONL event stream into the normalized agent.Event the monitor consumes.
Index ¶
- func Analyze(args []string, resultFile string, allowJSON bool) agent.Analysis
- func Subcommand(args []string) string
- type Event
- type FileChange
- type Item
- type Provider
- func (Provider) Analyze(args []string, resultFile string, allowJSON bool) agent.Analysis
- func (Provider) BinCandidates() []string
- func (Provider) BinEnv() string
- func (Provider) Doctor(bin string, run agent.RunFunc) agent.DoctorReport
- func (Provider) Name() string
- func (Provider) ParseLine(line string) (agent.Event, bool)
- func (Provider) ReviewArgs(spec agent.ReviewSpec) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Analyze ¶
Analyze decides how to run codex. For `exec`, it defaults the model (and, only when it also picks the model, the reasoning effort) unless the caller supplied that setting via -m/--model, -c/--config, or a -p/--profile. When JSON is not disabled, it also injects `--json` (for event monitoring) and, unless the caller already set one, `--output-last-message <resultFile>` as a reliable final-answer backup. Exec-specific flags are placed right after the `exec` token, where they apply to exec and any of its sub-subcommands (review/resume).
func Subcommand ¶
Subcommand returns the first positional token in args — codex's subcommand (e.g. "exec", "review", "login") — skipping flags and their values. Returns "" if there is no positional (bare `codex`, which opens the TUI).
Types ¶
type Event ¶
type Event struct {
Type string `json:"type"`
ThreadID string `json:"thread_id,omitempty"`
Item *Item `json:"item,omitempty"`
Usage *agent.Usage `json:"usage,omitempty"`
Error json.RawMessage `json:"error,omitempty"`
Message string `json:"message,omitempty"`
}
Event is a single line of the `codex exec --json` stream.
type FileChange ¶
FileChange describes one edited path inside a file_change item.
type Item ¶
type Item struct {
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Text string `json:"text,omitempty"`
Command string `json:"command,omitempty"`
AggregatedOutput string `json:"aggregated_output,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
Status string `json:"status,omitempty"`
Server string `json:"server,omitempty"`
Tool string `json:"tool,omitempty"`
Query string `json:"query,omitempty"`
Review string `json:"review,omitempty"`
Changes []FileChange `json:"changes,omitempty"`
Summary json.RawMessage `json:"summary,omitempty"`
}
Item is the payload of item.started / item.updated / item.completed events.
type Provider ¶
type Provider struct{}
Provider drives the OpenAI Codex CLI.
func (Provider) Analyze ¶
Analyze injects the `exec --json` / `--output-last-message` flags that make a codex run observable. See the package-level Analyze.
func (Provider) BinCandidates ¶
func (Provider) Doctor ¶
Doctor checks that codex is installed and responding via `codex --version` and `codex doctor --json` (which covers install/config/auth/runtime health).
func (Provider) ParseLine ¶
ParseLine normalizes a `codex exec --json` line into an agent.Event: it maps the phase/summary via Describe, tracks command/tool items for the watchdog, captures the final agent_message (or review payload) as the result, and flags error/turn.failed lines as failures.
func (Provider) ReviewArgs ¶
func (Provider) ReviewArgs(spec agent.ReviewSpec) ([]string, error)
ReviewArgs builds a native `codex exec review` invocation; codex has a purpose-built reviewer, so we use it rather than a constructed prompt.