codexcontract

package
v1.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package codexcontract centralizes Codex CLI protocol constants.

The Codex CLI evolves quickly; keeping flags and event type strings here makes compatibility updates localized.

Index

Constants

View Source
const (
	EventThreadStarted = "thread.started"
	EventTurnStarted   = "turn.started"
	EventTurnCompleted = "turn.completed"
	EventTurnFailed    = "turn.failed"
	EventItemStarted   = "item.started"
	EventItemUpdated   = "item.updated"
	EventItemCompleted = "item.completed"
	EventError         = "error"

	// Legacy/compat event types seen in older wrappers or test fakes.
	EventContent   = "content"
	EventText      = "text"
	EventAssistant = "assistant"
	EventMessage   = "message"
	EventToolCall  = "tool_call"
	EventDone      = "done"
	EventComplete  = "complete"
	EventEnd       = "end"
	EventUsage     = "usage"
	EventSession   = "session"
	EventResult    = "result"
)

Canonical JSONL event types from codex exec --json.

View Source
const (
	ItemAgentMessage = "agent_message"
	ItemReasoning    = "reasoning"
)

Item types we can interpret in headless mode.

View Source
const (
	CommandExec   = "exec"
	CommandResume = "resume"

	FlagJSON                              = "--json"
	FlagModel                             = "--model"
	FlagSandbox                           = "--sandbox"
	FlagAskForApproval                    = "--ask-for-approval"
	FlagFullAuto                          = "--full-auto"
	FlagYolo                              = "--yolo"
	FlagDangerouslyBypassApprovalsSandbox = "--dangerously-bypass-approvals-and-sandbox"
	FlagCD                                = "--cd"
	FlagAddDir                            = "--add-dir"
	FlagImage                             = "--image"
	FlagSearch                            = "--search"
	FlagProfile                           = "--profile"
	FlagLocalProvider                     = "--local-provider"
	FlagConfig                            = "-c"
	FlagSkipGitRepoCheck                  = "--skip-git-repo-check"
	FlagOutputSchema                      = "--output-schema"
	FlagOutputLastMessage                 = "--output-last-message"
	FlagAll                               = "--all"
	FlagOSS                               = "--oss"
	FlagEnable                            = "--enable"
	FlagDisable                           = "--disable"
	FlagColor                             = "--color"

	FlagVersion = "--version"
)

Codex CLI commands and flags used by this library.

View Source
const TestedCLIVersion = "0.98.0"

TestedCLIVersion is the Codex CLI version this package was validated against.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLIVersion

type CLIVersion struct {
	Major int
	Minor int
	Patch int
	Raw   string
}

CLIVersion represents a parsed semver-like CLI version.

func CheckVersion

func CheckVersion(codexPath string) *CLIVersion

CheckVersion detects CLI version and logs compatibility warnings.

func DetectCLIVersion

func DetectCLIVersion(codexPath string) (*CLIVersion, error)

DetectCLIVersion runs codex --version and parses the result.

func MustParseVersion

func MustParseVersion(s string) *CLIVersion

MustParseVersion parses a version and panics on invalid input.

func ParseVersion

func ParseVersion(s string) (*CLIVersion, error)

ParseVersion parses versions like "0.34.1".

func (*CLIVersion) Compare

func (v *CLIVersion) Compare(other *CLIVersion) int

Compare returns -1 when v < other, 0 when equal, and 1 when v > other.

func (*CLIVersion) IsNewerThan

func (v *CLIVersion) IsNewerThan(other *CLIVersion) bool

IsNewerThan reports whether v is newer than other.

func (*CLIVersion) WarnIfUntested

func (v *CLIVersion) WarnIfUntested()

WarnIfUntested warns when runtime CLI is newer than tested version.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL