Documentation
¶
Overview ¶
Package codex implements the Runner-side adapter for `codex app-server`. The adapter deliberately keeps the wire objects as JSON: Codex publishes a versioned schema and may add notification fields without requiring a Runner release. Only the stable identifiers needed by AgentRelay are typed here.
Index ¶
- Constants
- func Authenticated(ctx context.Context, binary string) (bool, error)
- func Version(ctx context.Context, binary string) (string, error)
- type AccountUsageResult
- type AccountUsageSummary
- type Client
- func (c *Client) Call(ctx context.Context, method string, params any, target any) error
- func (c *Client) Close() error
- func (c *Client) CompactThread(ctx context.Context, threadID string) error
- func (c *Client) Done() <-chan struct{}
- func (c *Client) GetAccountUsage(ctx context.Context) (AccountUsageResult, error)
- func (c *Client) GetRateLimits(ctx context.Context) (RateLimitsResult, error)
- func (c *Client) InterruptTurn(ctx context.Context, threadID, turnID string) error
- func (c *Client) ListModels(ctx context.Context) (ModelListResult, error)
- func (c *Client) Notify(method string, params any) error
- func (c *Client) Respond(id json.RawMessage, result any, responseErr error) error
- func (c *Client) ResumeThread(ctx context.Context, threadID, cwd, model string) error
- func (c *Client) ResumeThreadState(ctx context.Context, threadID, cwd, model string) (ThreadResult, error)
- func (c *Client) ResumeThreadStateWithOptions(ctx context.Context, threadID, cwd string, options ExecutionOptions) (ThreadResult, error)
- func (c *Client) ResumeThreadWithOptions(ctx context.Context, threadID, cwd string, options ExecutionOptions) error
- func (c *Client) StartThread(ctx context.Context, cwd, model string) (string, error)
- func (c *Client) StartThreadWithOptions(ctx context.Context, cwd string, options ExecutionOptions) (string, error)
- func (c *Client) StartTurn(ctx context.Context, threadID, message, model string) (string, error)
- func (c *Client) StartTurnWithInputs(ctx context.Context, threadID string, input []TurnInput, ...) (string, error)
- func (c *Client) StartTurnWithOptions(ctx context.Context, threadID, message string, options ExecutionOptions) (string, error)
- func (c *Client) SteerTurn(ctx context.Context, threadID, turnID, message string) error
- func (c *Client) SteerTurnWithInputs(ctx context.Context, threadID, turnID string, input []TurnInput) error
- type CreditsSnapshot
- type ExecutionOptions
- type Handlers
- type Model
- type ModelListResult
- type Notification
- type RateLimitSnapshot
- type RateLimitWindow
- type RateLimitsResult
- type ReasoningEffortOption
- type ServerRequest
- type ServiceTierOption
- type ThreadResult
- type TurnInput
- type TurnResult
Constants ¶
const DefaultBinary = "codex"
Variables ¶
This section is empty.
Functions ¶
func Authenticated ¶
Authenticated asks Codex CLI whether the local user has completed sign-in. It intentionally relies on the CLI status command instead of reading ~/.codex/auth.json, so AgentRelay never handles OpenAI credentials.
Types ¶
type AccountUsageResult ¶
type AccountUsageResult struct {
Summary AccountUsageSummary `json:"summary"`
}
type AccountUsageSummary ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func Start ¶
Start launches one long-lived app-server process. Codex owns authentication and model configuration on the Runner host; AgentRelay never receives those credentials.
func (*Client) CompactThread ¶
func (*Client) GetAccountUsage ¶
func (c *Client) GetAccountUsage(ctx context.Context) (AccountUsageResult, error)
func (*Client) GetRateLimits ¶
func (c *Client) GetRateLimits(ctx context.Context) (RateLimitsResult, error)
func (*Client) InterruptTurn ¶
func (*Client) ListModels ¶
func (c *Client) ListModels(ctx context.Context) (ModelListResult, error)
func (*Client) ResumeThread ¶
func (*Client) ResumeThreadState ¶
func (*Client) ResumeThreadStateWithOptions ¶
func (c *Client) ResumeThreadStateWithOptions(ctx context.Context, threadID, cwd string, options ExecutionOptions) (ThreadResult, error)
func (*Client) ResumeThreadWithOptions ¶
func (*Client) StartThread ¶
func (*Client) StartThreadWithOptions ¶
func (*Client) StartTurnWithInputs ¶
func (*Client) StartTurnWithOptions ¶
type CreditsSnapshot ¶
type ExecutionOptions ¶
type ExecutionOptions struct {
Model string
ReasoningEffort string
ServiceTier string
CollaborationMode string
PermissionMode string
}
ExecutionOptions are the user-visible Codex controls advertised by the local App Server. Empty values intentionally defer to the local Codex defaults instead of inventing cloud-side defaults.
type Handlers ¶
type Handlers struct {
Notification func(Notification)
Request func(ServerRequest)
Stderr func(string)
Exit func(error)
}
type Model ¶
type Model struct {
ID string `json:"id"`
Model string `json:"model"`
DisplayName string `json:"displayName"`
Description string `json:"description"`
IsDefault bool `json:"isDefault"`
Hidden bool `json:"hidden"`
DefaultReasoningEffort string `json:"defaultReasoningEffort"`
SupportedReasoningEfforts []ReasoningEffortOption `json:"supportedReasoningEfforts"`
DefaultServiceTier *string `json:"defaultServiceTier"`
ServiceTiers []ServiceTierOption `json:"serviceTiers"`
}
type ModelListResult ¶
type Notification ¶
type Notification struct {
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
type RateLimitSnapshot ¶
type RateLimitSnapshot struct {
LimitID *string `json:"limitId"`
LimitName *string `json:"limitName"`
PlanType *string `json:"planType"`
Primary *RateLimitWindow `json:"primary"`
Secondary *RateLimitWindow `json:"secondary"`
Credits *CreditsSnapshot `json:"credits"`
}
type RateLimitWindow ¶
type RateLimitsResult ¶
type RateLimitsResult struct {
RateLimits RateLimitSnapshot `json:"rateLimits"`
RateLimitsByLimitID map[string]RateLimitSnapshot `json:"rateLimitsByLimitId"`
}
type ReasoningEffortOption ¶
type ServerRequest ¶
type ServerRequest struct {
ID json.RawMessage `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
type ServiceTierOption ¶
type ThreadResult ¶
type TurnInput ¶
TurnInput mirrors the stable input variants accepted by turn/start. Keeping the payload open lets newer Codex versions add optional fields without a Runner release while the constructors below enforce the variants we emit.
func LocalImageInput ¶
func MentionInput ¶
type TurnResult ¶
type TurnResult struct {
Turn struct {
ID string `json:"id"`
} `json:"turn"`
}