Documentation
¶
Overview ¶
Package codex adapts the native Codex CLI app-server protocol to the common agent contract.
Index ¶
- Constants
- Variables
- func Environment(opts Options) []string
- func RunInteractive(ctx context.Context, opts Options, stdio agent.IO, ...) error
- func Sections() map[agent.Section]reflect.Type
- type Agent
- func (a *Agent) AuthStatus(ctx context.Context) (agent.AuthStatus, error)
- func (a *Agent) Diagnostics(ctx context.Context) (agent.Diagnostics, error)
- func (*Agent) Info() agent.Info
- func (a *Agent) Interactive(ctx context.Context, stdio agent.IO, command agent.InteractiveCommand) error
- func (a *Agent) Logout(ctx context.Context) error
- func (a *Agent) Models(ctx context.Context) ([]agent.Model, error)
- func (*Agent) Name() string
- func (a *Agent) ProfileDir() string
- func (*Agent) ProviderSections() map[agent.Section]reflect.Type
- func (a *Agent) Start(parent context.Context, req agent.Request, onEvent agent.EventFunc) (agent.Conversation, error)
- func (a *Agent) StartLogin(ctx context.Context, req agent.LoginRequest) (agent.Login, error)
- func (a *Agent) Usage(ctx context.Context) (agent.Usage, error)
- func (*Agent) Validate(req *agent.Request) error
- func (a *Agent) Version(ctx context.Context) (string, error)
- type AuthFields
- type Options
- type RequestFields
- type RequestOptions
- type ResultFields
- type SubscriptionFields
- type ThreadUsage
Constants ¶
const ( Name = "codex" Binary = "codex" )
const ( LoginChatGPTDeviceCode = "chatgpt_device_code" LoginChatGPT = "chatgpt" )
Native login methods. Device code works from any machine; chatgpt needs the browser on the gateway host because the native callback listens on localhost.
Variables ¶
var ( ReasoningSummaries = agent.EnumOf[RequestOptions]("ReasoningSummary") ApprovalsReviewers = agent.EnumOf[RequestOptions]("ApprovalsReviewer") )
var Descriptor = agent.Info{ Name: Name, Title: "Codex CLI", Provider: "OpenAI", Binary: Binary, Capabilities: []agent.Capability{ agent.CapabilityAuth, agent.CapabilityCustomAgents, agent.CapabilityDiagnostics, agent.CapabilityHooks, agent.CapabilityInteractive, agent.CapabilityMCP, agent.CapabilityModels, agent.CapabilityNativeControl, agent.CapabilityPartialMessages, agent.CapabilityPermissions, agent.CapabilityPlugins, agent.CapabilitySessionFork, agent.CapabilitySessions, agent.CapabilitySkills, agent.CapabilitySubscriptionUsage, agent.CapabilityTools, }, LoginMethods: []string{LoginChatGPTDeviceCode, LoginChatGPT}, TestedVersion: version, Docs: "docs/agents/codex-cli.md", }
Functions ¶
func Environment ¶
func RunInteractive ¶
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func (*Agent) AuthStatus ¶
AuthStatus implements agent.Agent with app-server account/read.
func (*Agent) Diagnostics ¶
func (*Agent) Interactive ¶
func (*Agent) Logout ¶
Logout implements agent.Authenticator with the native `codex logout` command.
func (*Agent) ProfileDir ¶
ProfileDir implements agent.ProfileReporter.
func (*Agent) ProviderSections ¶
ProviderSections implements agent.SectionDescriber.
func (*Agent) StartLogin ¶
StartLogin runs account/login/start on a dedicated app-server process that stays alive until account/login/completed arrives.
type AuthFields ¶
type AuthFields struct {
Method string `json:"method,omitempty" doc:"Native account type, e.g. chatgpt or apiKey."`
}
AuthFields are Codex's fields of the auth status provider section.
type Options ¶
type Options struct {
Binary string
// ProfileDir is agent.ProfileNative (Codex's own ~/.codex) or a custom absolute directory
// exported as CODEX_HOME.
ProfileDir string
HomeDir string
User string
WorkDir string
TempDir string
ProxyEnv []string // Standard proxy variables (NAME=value), passed on unchanged.
Path string
SandboxMode agent.SandboxMode
MaxOutputBytes int64
CommandTimeout time.Duration
Logger *slog.Logger
}
type RequestFields ¶
type RequestFields struct {
Method string `json:"method" doc:"Native app-server request method, e.g. item/commandExecution/requestApproval."`
}
RequestFields are Codex's fields of a permission or control request's provider section.
type RequestOptions ¶
type RequestOptions struct {
// Config holds native config overrides (mcp_servers, features, tools, web_search, ...).
Config map[string]any `` /* 140-byte string literal not displayed */
DeveloperInstructions string `json:"developer_instructions,omitempty" doc:"Thread developerInstructions."`
ApprovalsReviewer string `json:"approvals_reviewer,omitempty" enum:"user,auto_review" doc:"Thread approvalsReviewer; needs tools.permissions ask."`
ServiceTier string `json:"service_tier,omitempty" doc:"Thread serviceTier."`
ReasoningSummary string `json:"reasoning_summary,omitempty" enum:"auto,concise,detailed,none" doc:"Turn summary."`
// DisabledPluginIDs replaces the thread's disabled plugins; an empty list clears it.
DisabledPluginIDs *[]string `json:"disabled_plugin_ids,omitempty" doc:"Turn disabledPluginIds; an empty list clears it."`
// SkillRoots add skill directories inside an allowed root or the workspace. They live in
// the run's own app-server process and are never written to the Codex config.
SkillRoots []string `json:"skill_roots,omitempty" doc:"Extra skill directories inside an allowed root or the workspace."`
}
RequestOptions are Codex app-server's native per-run options (the request "options" object). See docs/agents/codex-cli.md.
func ParseOptions ¶
func ParseOptions(req *agent.Request) (RequestOptions, error)
ParseOptions decodes and validates raw options for req.
type ResultFields ¶
type ResultFields struct {
Reason string `json:"reason" doc:"Native turn status, e.g. completed, interrupted or failed."`
// Thread is the native cumulative usage of the thread, when Codex reported it.
Thread *ThreadUsage `json:"thread,omitempty"`
}
ResultFields are Codex's fields of a turn result's provider section.
type SubscriptionFields ¶
type SubscriptionFields struct {
WindowMinutes map[string]int64 `json:"window_minutes,omitempty" doc:"Window length in minutes, by window id."`
}
SubscriptionFields are Codex's fields of the subscription usage provider section.
type ThreadUsage ¶
ThreadUsage is the native cumulative token usage of a thread. It is kept across resumes and a fork starts from its parent's.