Documentation
¶
Overview ¶
Package codex implements the Codex agent via the Codex App Server.
Index ¶
- Constants
- type Agent
- func (a *Agent) Execute(ctx context.Context, msgs []*bridge.Message) (*agent.Result, error)
- func (a *Agent) IsRunning() bool
- func (a *Agent) Name() string
- func (a *Agent) SessionID() string
- func (a *Agent) SetMCPServerAddr(addr string)
- func (a *Agent) Start(ctx context.Context) error
- func (a *Agent) Status() *agent.Status
- func (a *Agent) Stop(ctx context.Context) error
- type ApproveCommandParams
- type ApproveFileParams
- type CommandRequestParams
- type ErrorParams
- type ExecuteParams
- type ExecuteResult
- type FileRequestParams
- type InitializeParams
- type InitializeResult
- type Notification
- type OutputParams
- type ProgressParams
- type RPCError
- type Request
- type Response
- type SessionStatusResult
- type Statistics
- type ToolCall
Constants ¶
const ( MethodInitialize = "initialize" MethodShutdown = "shutdown" MethodExecute = "execute" MethodCancel = "cancel" MethodApproveCommand = "approveCommand" MethodApproveFile = "approveFile" MethodGetSessionStatus = "getSessionStatus" )
Method names for Codex App Server.
const ( NotifyCommandRequest = "commandRequest" NotifyFileRequest = "fileRequest" NotifyProgress = "progress" NotifyOutput = "output" NotifyError = "error" )
Notification methods from Codex.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent implements the Agent interface for Codex.
func (*Agent) SetMCPServerAddr ¶
SetMCPServerAddr sets the MCP server address for bridge tools.
type ApproveCommandParams ¶
type ApproveCommandParams struct {
RequestID string `json:"requestId"`
Command string `json:"command"`
Approved bool `json:"approved"`
}
ApproveCommandParams for command approval.
type ApproveFileParams ¶
type ApproveFileParams struct {
RequestID string `json:"requestId"`
FilePath string `json:"filePath"`
Approved bool `json:"approved"`
}
ApproveFileParams for file change approval.
type CommandRequestParams ¶
type CommandRequestParams struct {
RequestID string `json:"requestId"`
Command string `json:"command"`
Description string `json:"description"`
}
CommandRequestParams for command approval requests.
type ErrorParams ¶
type ErrorParams struct {
Code string `json:"code"`
Message string `json:"message"`
Details string `json:"details,omitempty"`
}
ErrorParams for error notifications.
type ExecuteParams ¶
type ExecuteParams struct {
Prompt string `json:"prompt"`
MaxTokens int `json:"maxTokens,omitempty"`
Timeout int `json:"timeout,omitempty"`
AutoApprove bool `json:"autoApprove,omitempty"`
Context map[string]string `json:"context,omitempty"`
}
ExecuteParams for the execute method.
type ExecuteResult ¶
type ExecuteResult struct {
Output string `json:"output"`
Done bool `json:"done"`
ToolCalls []ToolCall `json:"toolCalls,omitempty"`
Statistics *Statistics `json:"statistics,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
ExecuteResult from the execute method.
type FileRequestParams ¶
type FileRequestParams struct {
RequestID string `json:"requestId"`
FilePath string `json:"filePath"`
Operation string `json:"operation"` // "create", "edit", "delete"
Description string `json:"description"`
}
FileRequestParams for file change approval requests.
type InitializeParams ¶
type InitializeParams struct {
WorkDir string `json:"workDir"`
Model string `json:"model,omitempty"`
AutoApprove bool `json:"autoApprove,omitempty"`
Environment map[string]string `json:"environment,omitempty"`
}
InitializeParams for the initialize method.
type InitializeResult ¶
type InitializeResult struct {
SessionID string `json:"sessionId"`
Capabilities []string `json:"capabilities,omitempty"`
}
InitializeResult from the initialize method.
type Notification ¶
type Notification struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params any `json:"params,omitempty"`
}
Notification represents a JSON-RPC 2.0 notification (no id field).
func NewNotification ¶
func NewNotification(method string, params any) *Notification
NewNotification creates a new JSON-RPC 2.0 notification.
type OutputParams ¶
type OutputParams struct {
Text string `json:"text"`
Stream string `json:"stream"` // "stdout" or "stderr"
}
OutputParams for streaming output.
type ProgressParams ¶
type ProgressParams struct {
Message string `json:"message"`
Percentage int `json:"percentage,omitempty"`
}
ProgressParams for progress updates.
type RPCError ¶
type RPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
RPCError represents a JSON-RPC 2.0 error.
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
ID int64 `json:"id"`
Method string `json:"method"`
Params any `json:"params,omitempty"`
}
Request represents a JSON-RPC 2.0 request.
func NewRequest ¶
NewRequest creates a new JSON-RPC 2.0 request.
type Response ¶
type Response struct {
JSONRPC string `json:"jsonrpc"`
ID int64 `json:"id"`
Result json.RawMessage `json:"result,omitempty"`
Error *RPCError `json:"error,omitempty"`
}
Response represents a JSON-RPC 2.0 response.
func (*Response) DecodeResult ¶
DecodeResult decodes a response result into the given type.
type SessionStatusResult ¶
type SessionStatusResult struct {
SessionID string `json:"sessionId"`
State string `json:"state"`
Running bool `json:"running"`
}
SessionStatusResult from getSessionStatus.
type Statistics ¶
type Statistics struct {
InputTokens int `json:"inputTokens"`
OutputTokens int `json:"outputTokens"`
DurationMs int `json:"durationMs"`
}
Statistics contains usage statistics.