Documentation
¶
Overview ¶
The record of the app server protocol of the Codex program and the client of it: the messages icebath sends and reads, as `codex app-server` speaks them on its standard streams. Their shapes are those of codex-rs/app-server-protocol in the Codex repository at rust-v0.125.0, the oldest release the runtime takes, and at the newest; a field a later release added says so
Index ¶
- Constants
- Variables
- type AccountResponse
- type AnswerList
- type Capabilities
- type Change
- type ChangeKind
- type ClientInfo
- type CommandAsk
- type ContentItem
- type Decision
- type Delta
- type DynamicTool
- type ElicitationAnswer
- type ElicitationAsk
- type Ended
- type ErrorNotice
- type FileChangeAsk
- type InitializeParams
- type InitializeResponse
- type Input
- type InputOption
- type InputQuestion
- type Item
- type Launch
- type ListParams
- type LoginCompleted
- type LoginParams
- type LoginResponse
- type MCPServerList
- type Model
- type ModelList
- type ModelListParams
- type NetworkContext
- type Permissions
- type PermissionsAnswer
- type PermissionsAsk
- type Plan
- type PlanStep
- type PluginList
- type Program
- func (p *Program) Alive() bool
- func (p *Program) Call(ctx context.Context, method string, params, result any) error
- func (p *Program) Close()
- func (p *Program) Done() <-chan struct{}
- func (p *Program) Notify(method string, params any) error
- func (p *Program) PID() int
- func (p *Program) Said() string
- func (p *Program) Settle(ctx context.Context) error
- func (p *Program) Tail(lines int) string
- type RateLimitSnapshot
- type RateLimitWindow
- type RateLimits
- type Rerouted
- type Scope
- type Thread
- type ThreadNameParams
- type ThreadNamed
- type ThreadParams
- type ThreadResponse
- type TokenUsage
- type Tokens
- type TokensAnswer
- type TokensAsk
- type ToolCallAnswer
- type ToolCallAsk
- type Turn
- type TurnError
- type TurnInterruptParams
- type TurnResponse
- type TurnStartParams
- type TurnSteerParams
- type TurnSteerResponse
- type UserInputAnswer
- type UserInputAsk
- type V1CommandAsk
- type V1PatchAsk
- type Version
- type Warning
Constants ¶
const ( MethodInitialize = "initialize" MethodThreadStart = "thread/start" MethodThreadResume = "thread/resume" MethodThreadArchive = "thread/archive" MethodThreadDelete = "thread/delete" MethodThreadName = "thread/name/set" MethodThreadCompact = "thread/compact/start" MethodTurnStart = "turn/start" MethodTurnSteer = "turn/steer" MethodTurnInterrupt = "turn/interrupt" MethodModelList = "model/list" MethodAccountRead = "account/read" MethodAccountLogin = "account/login/start" MethodAccountLoginStop = "account/login/cancel" MethodAccountLogout = "account/logout" MethodAccountRateLimits = "account/rateLimits/read" MethodPluginList = "plugin/list" MethodMCPServerStatus = "mcpServerStatus/list" )
Requests icebath makes of the program
const ( AskCommand = "item/commandExecution/requestApproval" AskFileChange = "item/fileChange/requestApproval" AskPermissions = "item/permissions/requestApproval" AskUserInput = "item/tool/requestUserInput" AskToolCall = "item/tool/call" AskElicitation = "mcpServer/elicitation/request" AskTokens = "account/chatgptAuthTokens/refresh" AskAttestation = "attestation/generate" // The approvals of the program's first protocol, which a thread started over the second never asks, answered all the same AskV1Command = "execCommandApproval" AskV1Patch = "applyPatchApproval" )
Requests the program makes of icebath
const ( NoticeError = "error" NoticeWarning = "warning" NoticeConfigWarning = "configWarning" NoticeDeprecation = "deprecationNotice" NoticeThreadStarted = "thread/started" NoticeTurnStarted = "turn/started" NoticeTurnCompleted = "turn/completed" NoticeTurnDiff = "turn/diff/updated" NoticeTurnPlan = "turn/plan/updated" NoticeItemStarted = "item/started" NoticeItemCompleted = "item/completed" NoticeAgentDelta = "item/agentMessage/delta" NoticePlanDelta = "item/plan/delta" NoticeReasoningDelta = "item/reasoning/textDelta" NoticeSummaryDelta = "item/reasoning/summaryTextDelta" NoticeSummaryPart = "item/reasoning/summaryPartAdded" NoticeCommandOutput = "item/commandExecution/outputDelta" NoticeFileChangeDelta = "item/fileChange/outputDelta" NoticePatchUpdated = "item/fileChange/patchUpdated" NoticeMCPProgress = "item/mcpToolCall/progress" NoticeTokenUsage = "thread/tokenUsage/updated" NoticeCompacted = "thread/compacted" NoticeRateLimits = "account/rateLimits/updated" NoticeRerouted = "model/rerouted" NoticeLoginCompleted = "account/login/completed" NoticeAccountUpdated = "account/updated" NoticeRequestResolved = "serverRequest/resolved" )
What the program tells icebath
const ( CodeInvalidRequest = -32600 CodeMethodNotFound = -32601 CodeInvalidParams = -32602 CodeInternal = -32603 )
Error codes of the protocol
const ( InputText = "text" InputImage = "image" InputLocalImage = "localImage" )
Kinds of input
const ( TurnCompleted = "completed" TurnInterrupted = "interrupted" TurnFailed = "failed" )
How a turn ended
const ( ItemUserMessage = "userMessage" ItemAgentMessage = "agentMessage" ItemPlan = "plan" ItemReasoning = "reasoning" ItemCommand = "commandExecution" ItemFileChange = "fileChange" ItemMCPToolCall = "mcpToolCall" ItemDynamicTool = "dynamicToolCall" ItemCollabAgent = "collabAgentToolCall" ItemWebSearch = "webSearch" ItemImageView = "imageView" ItemImageMade = "imageGeneration" ItemEnteredReview = "enteredReviewMode" ItemExitedReview = "exitedReviewMode" ItemCompaction = "contextCompaction" )
Kinds of items
const ( ChangeAdd = "add" ChangeDelete = "delete" ChangeUpdate = "update" )
Kinds of change of a file
const ( Accept = "accept" AcceptForSession = "acceptForSession" Decline = "decline" Cancel = "cancel" )
Answers to an ask of leave
const ( ContentText = "inputText" ContentImage = "inputImage" )
Kinds of the parts of a tool's answer
const ( ElicitForm = "form" ElicitURL = "url" ElicitOpenAIForm = "openai/form" ElicitOpenAIForm2 = "openaiForm" ElicitVerify = "openai/userVerification" )
Kinds of elicitation
const ( ElicitAccept = "accept" ElicitDecline = "decline" ElicitCancel = "cancel" )
Answers to an elicitation
const ( LoginAPIKey = "apiKey" LoginChatGPT = "chatgpt" LoginDeviceCode = "chatgptDeviceCode" LoginTokens = "chatgptAuthTokens" AccountChatGPT = "chatgpt" AccountAPIKey = "apiKey" AccountBedrock = "amazonBedrock" AccountGoogleGCP = "gcp" )
Sign-ins of account/login/start
const NoticeInitialized = "initialized"
Notification icebath sends once the program answered initialize
const Purpose = "codex-app-server"
Purpose the ledger of the profile records an app server under
Variables ¶
var Efforts = Version{0, 138, 0}
Release from which a turn takes any effort its model names, max and ultra among them; those before take none above xhigh
var Least = Version{0, 125, 0}
Oldest release of Codex the runtime takes: the first whose app server carries every request and answer it uses
var OlderReasoningDeltas = []string{"item/reasoning/delta", "item/reasoning/summaryDelta"}
Older names of the reasoning deltas, which releases before the second protocol settled sent
var Rejecting = Version{0, 145, 0}
Release from which a refusal of the first protocol's approvals carries its reason
var Unsuccessful = []string{"failed", "declined"}
Statuses an item ends with that are no success
Functions ¶
This section is empty.
Types ¶
type AccountResponse ¶
type AccountResponse struct {
Account *struct {
Type string `json:"type"`
Email string `json:"email"`
PlanType string `json:"planType"`
} `json:"account"`
RequiresOpenAIAuth bool `json:"requiresOpenaiAuth"`
}
The account the program is signed in with
type AnswerList ¶
type AnswerList struct {
Answers []string `json:"answers"`
}
type Capabilities ¶
type Capabilities struct {
ExperimentalAPI bool `json:"experimentalApi"`
OptOut []string `json:"optOutNotificationMethods,omitempty"`
}
What icebath can take: the experimental part of the protocol, which dynamic tools and a sign-in by tokens belong to
type Change ¶
type Change struct {
Path string `json:"path"`
Kind ChangeKind `json:"kind"`
Diff string `json:"diff"`
}
One file a fileChange item changes: its path, the kind of change, and the change as text, which is the whole file for a file added or removed and a unified diff for one changed
type ChangeKind ¶
type ClientInfo ¶
type CommandAsk ¶
type CommandAsk struct {
ThreadID string `json:"threadId"`
TurnID string `json:"turnId"`
ItemID string `json:"itemId"`
Reason string `json:"reason"`
Command string `json:"command"`
Cwd string `json:"cwd"`
// Kind of ask, command when absent: humanCommand and writeStdin came after rust-v0.125.0
Kind string `json:"kind"`
Network *NetworkContext `json:"networkApprovalContext"`
}
The program asks leave to run a command
type ContentItem ¶
type ContentItem struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ImageURL string `json:"imageUrl,omitempty"`
}
One part of what a tool of icebath's gave back
type Delta ¶
type Delta struct {
ItemID string `json:"itemId"`
Delta string `json:"delta"`
// Older releases put the text here
Text string `json:"text"`
}
Text of a delta notification
type DynamicTool ¶
type DynamicTool struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema map[string]any `json:"inputSchema"`
}
A tool of icebath's the thread is offered, in the flat form every release takes
type ElicitationAnswer ¶
type ElicitationAsk ¶
type ElicitationAsk struct {
ThreadID string `json:"threadId"`
TurnID string `json:"turnId"`
ServerName string `json:"serverName"`
Mode string `json:"mode"`
Message string `json:"message"`
Schema json.RawMessage `json:"requestedSchema"`
URL string `json:"url"`
Title string `json:"title"`
Text string `json:"description"`
}
A server of the thread's MCP servers asks the person something: a form to fill in, an address to open, or a check of who they are
type Ended ¶
type Ended struct {
Doing string
// The end of what it wrote to its standard error, else how it ended
Said string
}
The program ended before it answered
type ErrorNotice ¶
type ErrorNotice struct {
Error TurnError `json:"error"`
WillRetry bool `json:"willRetry"`
ThreadID string `json:"threadId"`
TurnID string `json:"turnId"`
}
The error notification: a turn's failure, which the program may try again itself
type FileChangeAsk ¶
type FileChangeAsk struct {
ThreadID string `json:"threadId"`
TurnID string `json:"turnId"`
ItemID string `json:"itemId"`
Reason string `json:"reason"`
GrantRoot string `json:"grantRoot"`
}
The program asks leave to change files
type InitializeParams ¶
type InitializeParams struct {
ClientInfo ClientInfo `json:"clientInfo"`
Capabilities *Capabilities `json:"capabilities,omitempty"`
}
type InitializeResponse ¶
type InitializeResponse struct {
UserAgent string `json:"userAgent"`
CodexHome string `json:"codexHome,omitempty"`
}
The program's answer to initialize; codexHome and the platform fields came after rust-v0.125.0
type Input ¶
type Input struct {
Type string `json:"type"`
// Of text
Text string `json:"text,omitempty"`
TextElements []any `json:"text_elements,omitempty"`
// Of an image by address, data addresses among them, and of a file of this computer
URL string `json:"url,omitempty"`
Path string `json:"path,omitempty"`
}
One part of what the person or icebath gives a turn
type InputOption ¶
type InputQuestion ¶
type Item ¶
type Item struct {
Type string `json:"type"`
ID string `json:"id"`
// agentMessage, plan
Text string `json:"text"`
Phase string `json:"phase"`
// reasoning
Summary []string `json:"summary"`
Content []string `json:"content"`
// commandExecution
Command string `json:"command"`
Cwd string `json:"cwd"`
Status string `json:"status"`
AggregatedOutput string `json:"aggregatedOutput"`
ExitCode *int `json:"exitCode"`
DurationMS *int64 `json:"durationMs"`
// fileChange
Changes []Change `json:"changes"`
// mcpToolCall, dynamicToolCall
Server string `json:"server"`
Tool string `json:"tool"`
Arguments json.RawMessage `json:"arguments"`
Result json.RawMessage `json:"result"`
Error json.RawMessage `json:"error"`
ContentItems json.RawMessage `json:"contentItems"`
Success *bool `json:"success"`
// webSearch, and what the search did, such as a page it opened
Query string `json:"query"`
Action json.RawMessage `json:"action"`
// imageView, imageGeneration
Path string `json:"path"`
SavedPath string `json:"savedPath"`
RevisedPrompt string `json:"revisedPrompt"`
// collabAgentToolCall
Prompt string `json:"prompt"`
Model string `json:"model"`
ReceiverThread []string `json:"receiverThreadIds"`
AgentsStates map[string]json.RawMessage `json:"agentsStates"`
// enteredReviewMode, exitedReviewMode
Review string `json:"review"`
// What the item holds whole, for a kind this record does not name
Raw json.RawMessage `json:"-"`
}
One item of a thread, as item/started and item/completed carry it: what every kind has, and the fields of each kind
type Launch ¶
type Launch struct {
Command string
Dir string
Env map[string]string
Log string
Config *config.Config
}
What starts an app server: the program, the folder it runs in, its environment, the log its standard error goes to, and the settings of the profile it runs for
type ListParams ¶
type ListParams struct {
Cursor string `json:"cursor,omitempty"`
}
type LoginCompleted ¶
type LoginCompleted struct {
LoginID string `json:"loginId"`
Success bool `json:"success"`
Error string `json:"error"`
}
How a sign-in the program ran ended
type LoginParams ¶
type LoginParams struct {
Type string `json:"type"`
APIKey string `json:"apiKey,omitempty"`
AccessToken string `json:"accessToken,omitempty"`
AccountID string `json:"chatgptAccountId,omitempty"`
PlanType *string `json:"chatgptPlanType,omitempty"`
}
Parameters of account/login/start for each way of signing in
type LoginResponse ¶
type LoginResponse struct {
Type string `json:"type"`
LoginID string `json:"loginId"`
AuthURL string `json:"authUrl"`
VerificationURL string `json:"verificationUrl"`
UserCode string `json:"userCode"`
}
Answer of account/login/start: where the person signs in, or the code they type there
type MCPServerList ¶
type MCPServerList struct {
Data []struct {
Name string `json:"name"`
Tools map[string]json.RawMessage `json:"tools"`
Auth string `json:"authStatus"`
Runtime string `json:"runtimeStatus"`
Failure string `json:"toolsError"`
} `json:"data"`
NextCursor *string `json:"nextCursor"`
}
Codex's own MCP servers and how each stands; runtimeStatus and toolsError came after rust-v0.125.0
type Model ¶
type Model struct {
ID string `json:"id"`
Model string `json:"model"`
DisplayName string `json:"displayName"`
Hidden bool `json:"hidden"`
IsDefault bool `json:"isDefault"`
Efforts []struct {
Effort string `json:"reasoningEffort"`
} `json:"supportedReasoningEfforts"`
}
A model the program offers
type ModelListParams ¶
type NetworkContext ¶
type Permissions ¶
type Permissions struct {
Network *struct {
Enabled *bool `json:"enabled"`
} `json:"network"`
FileSystem *struct {
Read []string `json:"read"`
Write []string `json:"write"`
} `json:"fileSystem"`
}
What a permissions ask names: the network, and folders by what may be done in them
type PermissionsAnswer ¶
type PermissionsAnswer struct {
Permissions json.RawMessage `json:"permissions"`
Scope string `json:"scope"`
}
type PermissionsAsk ¶
type PermissionsAsk struct {
ThreadID string `json:"threadId"`
TurnID string `json:"turnId"`
ItemID string `json:"itemId"`
Cwd string `json:"cwd"`
Reason string `json:"reason"`
Permissions json.RawMessage `json:"permissions"`
}
The program asks for more than its sandbox allows: the network, or folders to read and write
type PluginList ¶
type PluginList struct {
Marketplaces []struct {
Name string `json:"name"`
Plugins []struct {
Name string `json:"name"`
Installed bool `json:"installed"`
Enabled *bool `json:"enabled"`
Availability string `json:"availability"`
} `json:"plugins"`
} `json:"marketplaces"`
}
Codex's own plugins, as plugin/list lists them by marketplace; availability came after rust-v0.125.0
type Program ¶
type Program struct {
// What it answered the handshake with
Hello InitializeResponse
// contains filtered or unexported fields
}
An app server icebath started, through the terminal host so it dies with icebath however icebath ends: the program, the connection to it and what it last wrote to its standard error
func Start ¶
func Start(ctx context.Context, tm *terminal.Terminal, l Launch, handler acp.Handler, version string) (*Program, error)
Starts `codex app-server` with its standard streams held by icebath, has it answer the handshake as a client that takes the experimental part of the protocol, and serves what it asks and tells through the handler until it ends
func (*Program) Call ¶
Asks the program and waits for its answer, read into result unless that is nil; a refusal is an *acp.Error
func (*Program) Close ¶
func (p *Program) Close()
Ends the conversation and the program: nothing more is written to it, which it ends on, and one that goes on is ended with everything it started
func (*Program) Said ¶
Why the program ended, as far as it said: the end of what it wrote to its standard error, else the code it ended with; empty while it runs and said nothing
type RateLimitSnapshot ¶
type RateLimitSnapshot struct {
LimitName string `json:"limitName"`
Primary *RateLimitWindow `json:"primary"`
Secondary *RateLimitWindow `json:"secondary"`
PlanType string `json:"planType"`
Reached string `json:"rateLimitReachedType"`
}
type RateLimitWindow ¶
type RateLimits ¶
type RateLimits struct {
RateLimits RateLimitSnapshot `json:"rateLimits"`
}
Limits of the account as the program reads them
type Rerouted ¶
type Rerouted struct {
FromModel string `json:"fromModel"`
ToModel string `json:"toModel"`
Reason string `json:"reason"`
}
The model the program moved a turn to from the one asked for
type Scope ¶
type Scope struct {
ThreadID string `json:"threadId"`
TurnID string `json:"turnId"`
Turn *Turn `json:"turn"`
Item json.RawMessage `json:"item"`
}
What a notification of a turn says of where it belongs
type ThreadNameParams ¶
type ThreadNamed ¶
type ThreadNamed struct {
ThreadID string `json:"threadId"`
}
type ThreadParams ¶
type ThreadParams struct {
ThreadID string `json:"threadId,omitempty"`
Model string `json:"model,omitempty"`
ModelProvider string `json:"modelProvider,omitempty"`
Cwd string `json:"cwd,omitempty"`
ApprovalPolicy string `json:"approvalPolicy,omitempty"`
Sandbox string `json:"sandbox,omitempty"`
Config map[string]any `json:"config,omitempty"`
DeveloperInstructions string `json:"developerInstructions,omitempty"`
// Offered at thread/start alone: a thread keeps the tools it started with
DynamicTools []DynamicTool `json:"dynamicTools,omitempty"`
}
Parameters of thread/start, and of thread/resume with the id of the thread
type ThreadResponse ¶
type ThreadResponse struct {
Thread Thread `json:"thread"`
Model string `json:"model"`
ModelProvider string `json:"modelProvider"`
// Where early releases put the id
SessionID string `json:"sessionId"`
ThreadID string `json:"threadId"`
}
Answer of thread/start and thread/resume: the thread, and the model and provider it runs on
func (ThreadResponse) ID ¶
func (r ThreadResponse) ID() string
Id of the thread an answer names, wherever the release put it
type TokenUsage ¶
type TokenUsage struct {
TokenUsage struct {
Total Tokens `json:"total"`
Last Tokens `json:"last"`
Window int64 `json:"modelContextWindow"`
} `json:"tokenUsage"`
}
Tokens of the thread: of its last request and in all, and the model's window
type TokensAnswer ¶
type ToolCallAnswer ¶
type ToolCallAnswer struct {
ContentItems []ContentItem `json:"contentItems"`
Success bool `json:"success"`
}
type ToolCallAsk ¶
type ToolCallAsk struct {
ThreadID string `json:"threadId"`
TurnID string `json:"turnId"`
CallID string `json:"callId"`
Namespace string `json:"namespace"`
Tool string `json:"tool"`
Arguments json.RawMessage `json:"arguments"`
}
The thread calls one of icebath's tools
type TurnError ¶
type TurnError struct {
Message string `json:"message"`
Info json.RawMessage `json:"codexErrorInfo"`
Details string `json:"additionalDetails"`
}
What went wrong in a turn, with what kind of failure the program made of it
type TurnInterruptParams ¶
type TurnResponse ¶
type TurnResponse struct {
Turn Turn `json:"turn"`
}
type TurnStartParams ¶
type TurnStartParams struct {
ThreadID string `json:"threadId"`
Input []Input `json:"input"`
Model string `json:"model,omitempty"`
Effort string `json:"effort,omitempty"`
Summary string `json:"summary,omitempty"`
// Speed tier of this turn and those after it: null asks for the standard one, absent keeps the thread's
ServiceTier *json.RawMessage `json:"serviceTier,omitempty"`
}
type TurnSteerParams ¶
type TurnSteerResponse ¶
type TurnSteerResponse struct {
TurnID string `json:"turnId"`
}
type UserInputAnswer ¶
type UserInputAnswer struct {
Answers map[string]AnswerList `json:"answers"`
}
type UserInputAsk ¶
type UserInputAsk struct {
ThreadID string `json:"threadId"`
TurnID string `json:"turnId"`
ItemID string `json:"itemId"`
Questions []InputQuestion `json:"questions"`
}
The program asks the person questions
type V1CommandAsk ¶
type V1CommandAsk struct {
CallID string `json:"callId"`
Command []string `json:"command"`
Cwd string `json:"cwd"`
Reason string `json:"reason"`
}
The approvals of the first protocol
type V1PatchAsk ¶
type Version ¶
type Version [3]int
Major, minor and patch of a release of Codex
func Check ¶
Release of the program as `codex --version` prints it, run with the environment given; an error in words a person reads when it does not run or names no release
func ParseVersion ¶
Release a text names, such as what `codex --version` prints or the user agent of the handshake; false when it names none