Documentation
¶
Index ¶
- func New(config v1.Config) v1.Tool
- func WriteCodexConfig(basePath string, cfg *CodexConfig) (string, error)
- type AgentInput
- type Codex
- func (in *Codex) AnalysisFollowUpRun(ctx context.Context, followUpPrompt string) error
- func (in *Codex) BabysitRun(ctx context.Context, bCtx *v1.BabysitContext) bool
- func (in *Codex) Configure(consoleURL, consoleToken string) error
- func (in *Codex) ConfigureBabysitRun() error
- func (in *Codex) OnMessage(f func(message *console.AgentMessageAttributes))
- func (in *Codex) Run(ctx context.Context, options ...exec.Option)
- type CodexConfig
- type DynamicToolContentItem
- type Features
- type FileChange
- type MCPContentBlock
- type MCPInput
- type MCPServer
- type MCPToolError
- type MCPToolResult
- type Model
- type ModelProviderConfig
- type ModelProviderInput
- type Profile
- type Project
- type SandboxWorkspaceWrite
- type ShellEnvPolicy
- type StreamEvent
- type StreamItem
- type TodoItem
- type TurnError
- type TurnUsage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteCodexConfig ¶
func WriteCodexConfig(basePath string, cfg *CodexConfig) (string, error)
Types ¶
type AgentInput ¶
type Codex ¶
type Codex struct {
v1.DefaultTool
// contains filtered or unexported fields
}
func (*Codex) AnalysisFollowUpRun ¶ added in v0.6.40
AnalysisFollowUpRun re-runs Codex with the analysis profile and followUpPrompt. Errors are returned to the caller and must not be sent on ErrorChan.
func (*Codex) BabysitRun ¶
func (*Codex) ConfigureBabysitRun ¶
func (*Codex) OnMessage ¶
func (in *Codex) OnMessage(f func(message *console.AgentMessageAttributes))
type CodexConfig ¶
type CodexConfig struct {
Projects map[string]*Project `toml:"projects,omitempty"`
ModelProviders map[string]*ModelProviderConfig `toml:"model_providers,omitempty"`
Profiles map[string]*Profile `toml:"profiles"`
MCPServers map[string]*MCPServer `toml:"mcp_servers"`
}
func BuildCodexConfig ¶
func BuildCodexConfig(repositoryDir string, agents []AgentInput, mcps []MCPInput, providers []ModelProviderInput) (*CodexConfig, error)
type DynamicToolContentItem ¶ added in v0.6.41
type DynamicToolContentItem struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
}
DynamicToolContentItem is a single output block for a "dynamic_tool_call" item.
type FileChange ¶
type FileChange struct {
Path string `json:"path,omitempty"`
Kind string `json:"kind,omitempty"` // e.g. "add", "modify", "delete"
}
FileChange describes a single file modification inside a "file_change" item.
type MCPContentBlock ¶ added in v0.6.41
MCPContentBlock is a single MCP content block inside MCPToolResult.Content.
type MCPInput ¶
type MCPInput struct {
Name string
Type string // Transport type: "stdio", "sse" or "http"
URL string
Command string
Args []string
Env map[string]string
Headers map[string]string // HTTP request headers, used for "http" transport
EnabledTools []string
DisabledTools []string
TrustPolicy string // e.g. "always" to auto-approve tool calls in exec mode
}
type MCPServer ¶
type MCPServer struct {
Type string `toml:"type,omitempty"` // Transport type: "stdio", "sse" or "http"
URL string `toml:"url,omitempty"` // For remote MCP (sse/http)
Command string `toml:"command,omitempty"` // For local MCP (stdio)
Args []string `toml:"args,omitempty"`
Env map[string]string `toml:"env,omitempty"`
Headers map[string]string `toml:"headers,omitempty"` // HTTP request headers for "http" transport
EnabledTools []string `toml:"enabled_tools,omitempty"`
DisabledTools []string `toml:"disabled_tools,omitempty"`
TrustPolicy string `toml:"trust_policy,omitempty"` // e.g. "always" to auto-approve tool calls in exec mode
}
type MCPToolError ¶
type MCPToolError struct {
Message string `json:"message,omitempty"`
}
MCPToolError holds the error payload for a failed "mcp_tool_call" item.
type MCPToolResult ¶ added in v0.6.41
type MCPToolResult struct {
Content []MCPContentBlock `json:"content,omitempty"`
StructuredContent json.RawMessage `json:"structured_content,omitempty"`
}
MCPToolResult is the result payload for a completed "mcp_tool_call" item. See https://takopi.dev/reference/runners/codex/exec-json-cheatsheet/
type ModelProviderConfig ¶
type ModelProviderConfig struct {
Name string `toml:"name,omitempty"`
BaseURL string `toml:"base_url,omitempty"`
EnvKey string `toml:"env_key,omitempty"`
}
ModelProviderConfig is serialized into [model_providers.<key>] in config.toml.
type ModelProviderInput ¶
type ModelProviderInput struct {
// Name is the key used to reference this provider from a Profile's ModelProvider field.
Name string
// BaseURL is the OpenAI-compatible API endpoint, e.g. "https://api.example.com/v1".
BaseURL string
// EnvKey is the name of the environment variable that holds the API key.
EnvKey string
}
ModelProviderInput is the user-facing input for registering a custom model provider.
type Profile ¶
type Profile struct {
Model string `toml:"model"`
ModelProvider string `toml:"model_provider,omitempty"`
SandboxMode string `toml:"sandbox_mode"`
ApprovalPolicy string `toml:"approval_policy"`
ModelReasoningEffort string `toml:"model_reasoning_effort"`
ShellEnvironmentPolicy *ShellEnvPolicy `toml:"shell_environment_policy,omitempty"`
Features *Features `toml:"features,omitempty"`
ModelInstructionsFile string `toml:"model_instructions_file,omitempty"`
SandboxWorkspaceWrite *SandboxWorkspaceWrite `toml:"sandbox_workspace_write,omitempty"`
}
type SandboxWorkspaceWrite ¶ added in v0.6.41
type ShellEnvPolicy ¶
type StreamEvent ¶
type StreamEvent struct {
// Type identifies the event kind, e.g. "thread.started", "turn.started",
// "item.started", "item.completed", "turn.completed".
Type string `json:"type"`
// Message is populated with "error" events.
Message string `json:"message"`
// ThreadID is set on "thread.started" events and carries the session
// identifier that must be forwarded to the API (analogous to session_id in Claude).
ThreadID string `json:"thread_id,omitempty"`
// Item is populated on "item.started" and "item.completed" events.
Item *StreamItem `json:"item,omitempty"`
// Usage is populated on "turn.completed" events and contains token usage statistics.
Usage *TurnUsage `json:"usage,omitempty"`
// Error is populated on "turn.failed" events.
Error *TurnError `json:"error,omitempty"`
}
StreamEvent is the top-level envelope for every JSON line emitted by `codex exec --json`.
type StreamItem ¶
type StreamItem struct {
// ID is the stable identifier for this item across started/completed pairs.
ID string `json:"id"`
// Type describes what kind of item this is: "reasoning", "agent_message", "todo_list",
// "command_execution", "dynamic_tool_call", "mcp_tool_call", "file_change", etc.
Type string `json:"type"`
// Text is populated for "reasoning" and "agent_message" items.
Text string `json:"text,omitempty"`
// Message is populated for Type "error" items.
Message string `json:"message,omitempty"`
// Command and output fields are populated for "command_execution" items.
Command string `json:"command,omitempty"`
AggregatedOutput string `json:"aggregated_output,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
Status string `json:"status,omitempty"`
// Items is populated for "todo_list" items.
Items []TodoItem `json:"items,omitempty"`
// Tool fields are populated for "mcp_tool_call" and "dynamic_tool_call" items.
Server string `json:"server,omitempty"`
Namespace string `json:"namespace,omitempty"`
Tool string `json:"tool,omitempty"`
Arguments json.RawMessage `json:"arguments,omitempty"`
Result *MCPToolResult `json:"result,omitempty"`
Error *MCPToolError `json:"error,omitempty"`
// ContentItems is populated for "dynamic_tool_call" items.
ContentItems []DynamicToolContentItem `json:"content_items,omitempty"`
Success *bool `json:"success,omitempty"`
// Query is populated for "web_search" items.
Query string `json:"query,omitempty"`
// Changes is populated for "file_change" items.
Changes []FileChange `json:"changes,omitempty"`
}
StreamItem is the payload carried inside "item.started" / "item.completed" events.